I attempt to left join these two dataframe by using this landline.merge(AreaCode, how = 'left', left_on = 'source', right_on = 'codes')
However the values become ALL null, what did I do wrongly?
edited 1 I have used following code to make sure the data type are the same.
landline['source'] = landline['source'].astype(str)
AreaCode['codes'] = AreaCode['codes'].astype(str)
- Failed merge
datetime source Day code area
0 2019-01-01 16:22:46 | | Tuesday | NaN | NaN
1 2019-01-02 09:33:29 | | Wednesday | NaN | NaN
2 2019-01-02 09:44:46 | | Wednesday | NaN | NaN
- landline dataframe
<class 'pandas.core.frame.DataFrame'>
Int64Index: 3562 entries, 0 to 7097
Data columns (total 3 columns):
# Column Non-Null Count Dtype
--- ------ -------------- -----
0 datetime 3555 non-null object
1 source 3562 non-null object
2 Day 3555 non-null object
dtypes: object(3)
memory usage: 111.3+ KB
- areacode dataframe
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 611 entries, 0 to 610
Data columns (total 2 columns):
# Column Non-Null Count Dtype
--- ------ -------------- -----
0 codes 611 non-null object
1 area 611 non-null object
dtypes: object(2)
memory usage: 9.7+ KB
landlinean empty string, while it's not true for 'codes' inareacode. So, there wasn't a match at all.sourceandcodescolumns are the samestrdata type, the combined result still empty..astype(str)?