python - Merging dataframes in pandas - Keep getting key error? -
i'm trying merge 2 data frames, testr , testc, keep getting key error on "channel id" , not sure problem is. dataframes have same size or have same datatype pd.merge work? here code merge .info() on each dataframe:
def matchid_rc(rev,cost): rc = pd.merge(rev, cost, on='channel id', how = 'outer') return rc testr.info() <class 'pandas.core.frame.dataframe'> int64index: 169 entries, 0 168 data columns (total 7 columns): channel id 169 non-null int64 channel name 169 non-null object impressions 169 non-null object fill rate 169 non-null object gross rev 169 non-null object impression fees 169 non-null object exchange fees 169 non-null object dtypes: int64(1), object(6) memory usage: 10.6+ kb testc.info() <class 'pandas.core.frame.dataframe'> int64index: 63 entries, 0 62 data columns (total 3 columns): channel id 62 non-null object campaign 63 non-null object ad spend 63 non-null float64 dtypes: float64(1), object(2) memory usage: 2.0+ kb
they need same data type. after all, can't compare whether string , integer same.
Comments
Post a Comment