The Below is the python code in jyputer. i want to merge two dataframe using different index name.
registrations =pd.DataFrame({'reg_id':[1,2,3,4],'name':['Andrew','Bobo','charie','David']})
login = pd.DataFrame({'login_id':[1,2,3,4],'name':['Xavier','Andrew','Yolanda',"Bobo"]})
registrations.columns=['reg_name','req_id']
pd.merge(registrations,login,how="inner",left_on="reg_name",right_on="name"
)
--------------------------------------------------------------------------
ValueError Traceback (most recent call last)
/Users/apple/Desktop/Machine Learning/Practice File/Contontiation.ipynb Cell 27 line 1
----> 1 pd.merge(registrations,login,how="inner",left_on="reg_name",right_on="name")
File /opt/anaconda3/lib/python3.11/site-packages/pandas/core/reshape/merge.py:169, in merge(left, right, how, on, left_on, right_on, left_index, right_index, sort, suffixes, copy, indicator, validate)
154 return _cross_merge(
155 left_df,
156 right_df,
(...)
166 copy=copy,
167 )
168 else:
--> 169 op = _MergeOperation(
170 left_df,
171 right_df,
172 how=how,
173 on=on,
174 left_on=left_on,
175 right_on=right_on,
176 left_index=left_index,
177 right_index=right_index,
178 sort=sort,
179 suffixes=suffixes,
180 indicator=indicator,
...
-> 1479 raise ValueError(msg)
1481 # datetimelikes must match exactly
1482 elif needs_i8_conversion(lk.dtype) and not needs_i8_conversion(rk.dtype):
ValueError: You are trying to merge on int64 and object columns for key ‘reg_name’. If you wish to proceed you should use pd.concat