Feature Type
-
[X] Adding new functionality to pandas
-
[ ] Changing existing functionality in pandas
-
[ ] Removing existing functionality in pandas
Problem Description
When passing a Pandas Index as a variable in either right_on or left_on in a pd.merge(), the result is a KeyError
KeyError: array(['label 1', 'label 2', 'label 3'], dtype=object)
The documentation says that you can pass "label or list, or array-like". While pd.Index() might not be exactly an array-like, it does seem counterproductive to exclude the very thing that should be referenced when merging...
Feature Description
Simple request: Please expand allowable datastructures for right_on and left_on to be "label, list, array-like, or index".
Alternative Solutions
Temporary solution is to covert pd.Index to_lists():
merged_df = pd.merge(
left=df_A,
right=df_B,
right_on=df_A.columns.to_list(),
left_on=df_B.columns.to_list(),
how="left",
)
Additional Context
I believe this probably just a simple "oh-yeah" moment...
Comment From: zslsally
take
Comment From: manikrishna-m
Is this fixed?
Comment From: manikrishna-m
Take