-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BUG: Left join on index with non-unique values removes name of index #55815
Comments
take |
Thanks for the report, confirmed on main. When the caller has distinct values (e.g. |
In addition to the left join there seems to be other inconsistencies as well. @rhshadrach - any thoughts on what the result naming behavior should be when joining on indexes? I don't see it documented. I think I would have expected the result to keep the left name in all cases except
|
If we always keep the left name, even when
I also like the simplicity of "keep names from the caller". |
Just to confirm - are you saying the current behavior is to always keep the name of the caller? It looks to me that your second example is keeping the name of |
Ah - whoops, thanks. In that case, your expectation is reasonable and agrees with current behavior in certain situations, I think that should be preferred. |
Pandas version checks
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandas.
I have confirmed this bug exists on the main branch of pandas.
Reproducible Example
Issue Description
Left joining on an index with non-unique values in dataframe "a" resets the name of the index to
None
.Expected Behavior
The column name should stay as "ID" in this case i.e. the name of the join column for dataframe "a".
Installed Versions
commit : e86ed37
python : 3.10.12.final.0
python-bits : 64
OS : Linux
OS-release : 5.10.60.1-microsoft-standard-WSL2
Version : #1 SMP Wed Aug 25 23:20:18 UTC 2021
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : C.UTF-8
LOCALE : en_US.UTF-8
pandas : 2.1.1
numpy : 1.24.3
pytz : 2023.3.post1
dateutil : 2.8.2
setuptools : 59.6.0
pip : 22.0.2
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 3.1.2
IPython : None
pandas_datareader : None
bs4 : None
bottleneck : None
dataframe-api-compat: None
fastparquet : None
fsspec : None
gcsfs : None
matplotlib : None
numba : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
zstandard : None
tzdata : 2023.3
qtpy : None
pyqt5 : None
The text was updated successfully, but these errors were encountered: