[Sample Code]
d = {
'country': ['IN', 'USA', 'USA', 'IN'],
'username': ['abi.g', 'pugal.g', 'jan.g', 'jacob.h'],
'email': ['[email protected]', '[email protected]', '[email protected]', '[email protected]'],
'ClusterID': ['', '4', '5', '9']
}
df1 = pd.DataFrame(d)
data = [
['USA', 3490.89, 'qcx_taskid85_duns250437449', '3'],
['JA', 1211, 'Pugal Gandi', '4'],
['USA', 3455.00, 'Janani Khannan', '6']
]
df2 = pd.DataFrame(data, columns=['country', 'salary', 'name', 'ClusterID'])
df1.reset_index(inplace=True, drop=True)
df2.reset_index(inplace=True, drop=True)
df1.loc[df1['ClusterID'] == df2['ClusterID']]
Qns: How to compare/filter the two columns using .loc, while the no. of records are different in pandas?
Thanks,
question from:
https://stackoverflow.com/questions/65640759/valueerror-can-only-compare-identically-labeled-series-objects-in-pandas 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…