Skip to content
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: DataFrame.merge(suffixes=) does not respect None #24782

Closed
simonjayhawkins opened this issue Jan 15, 2019 · 3 comments

Comments

@simonjayhawkins
Copy link
Member

commented Jan 15, 2019

>>> import pandas as pd
>>> print(pd.__version__)
0.24.0rc1+6.gabfe72d7c.dirty
>>> from pandas import DataFrame
>>> df = DataFrame([1])
>>> df
   0
0  1
>>>
>>> df.columns
RangeIndex(start=0, stop=1, step=1)
>>>
>>> result = df.merge(df, left_index=True, right_index=True, suffixes=(None,'_dup'))
>>> result
   0None  0_dup
0      1      1
>>>
>>> result.columns
Index(['0None', '0_dup'], dtype='object')
>>>
>>> expected = result.rename(columns = {'0None':0})
>>> expected
   0  0_dup
0  1      1
>>>
>>> expected.columns
Index([0, '0_dup'], dtype='object')

specifying an empty string changes the dtype of the column label

>>> result = df.merge(df, left_index=True, right_index=True, suffixes=('','_dup'))
>>> result
   0  0_dup
0  1      1
>>> result.columns
Index(['0', '0_dup'], dtype='object')
@WillAyd

This comment has been minimized.

Copy link
Member

commented Jan 15, 2019

Thanks for the report. Makes sense to have a more robust handling of None here - PRs are always welcome

@charlesdong1991

This comment has been minimized.

Copy link
Contributor

commented Jan 17, 2019

I am on it!

@jreback jreback added this to the 0.25.0 milestone Feb 4, 2019

@simonjayhawkins

This comment has been minimized.

Copy link
Member Author

commented Feb 6, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.