0
我正在合并熊猫中的两个数据帧。熊猫合并只返回列名
df.head()
index business_id label
0 204149 3034 0
1 48723 3034 0
2 94586 3034 0
3 74369 3034 0
4 95287 3034 0
lst.head()
index path_to_image
0 10 ./train_photos/10.jpg
1 100003 ./train_photos/100003.jpg
2 100007 ./train_photos/100007.jpg
3 100008 ./train_photos/100008.jpg
4 100009 ./train_photos/100009.jpg
它只返回列首。
pd.merge(lst, df, on='index')
index path_to_image business_id label
我已经检查:
- 行数是相等的。
- 从一个数据中选择几个值,我发现它们与第二个数据中的行匹配。
- 两栏均为
int64
。
我怀疑什么原因:
- 缺失值?
- 重复?
数据更新
Out[515]:
{'business_id': [3034, 3034, 3034, 3034, 3034],
'index': [204149, 48723, 94586, 74369, 95287],
'label': [0, 0, 0, 0, 0]}
Out[516]:
{'index': ['10', '100003', '100007', '100008', '100009'],
'path_to_image': ['./train_photos/10.jpg',
'./train_photos/100003.jpg',
'./train_photos/100007.jpg',
'./train_photos/100008.jpg',
'./train_photos/100009.jpg']}
lst.index.dtype给你什么?同上'df.index.dtype'? –
您描述数据框的方法不清楚(对我而言)。请发布'df.head()。to_dict('list')'和'lst.head()。to_dict('list')',这样我们就可以看到原始数据并重现问题。 – unutbu
@AmiTavory选中。两个'int64'。 –