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'。 –