Consistently getting a keyerror when I try to merge two data frames. The code:
c = pd.merge(a, b, on='video_id', how='left')
Based on internet research I double checked the dtype and coerced both to int:
a = pd.read_csv(filename, index_col=False, dtype={'video_id': np.int64}, low_memory=False)
b = pd.read_csv(videoinfo, index_col=False, dtype={'video_id': np.int64})
Renamed the columns (to make sure they match):
a.columns.values[2] = "video_id"
b.columns.values[0] = "video_id"
Coerced to df:
c = pd.merge(pd.DataFrame(a), pd.DataFrame(b), on='video_id', how='left')
Out of ideas as to why I'm still getting the keyerror. And it's always "KeyError: 'video_id'"
解决方案