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

pandas.concat removes the name of the index column for string index columns #27053

Closed
AlexFuster opened this issue Jun 26, 2019 · 1 comment
Closed
Labels
Duplicate Report Duplicate issue or pull request Reshaping Concat, Merge/Join, Stack/Unstack, Explode

Comments

@AlexFuster
Copy link

Code Sample, a copy-pastable example if possible

df0=pd.DataFrame({'index':['a','b'],'foo':[1,2]}).set_index('index')
df1=pd.DataFrame({'index':['b','c'],'bar':[3,4]}).set_index('index')
pd.concat([df0,df1],axis=1)

Problem description

pandas.concat removes the name of the index column when concatenating dataframes with string typed index column, giving as a result:

foo bar
a 1.0 NaN
b 2.0 3.0
c NaN 4.0

Expected Output

index foo bar
a 1.0 NaN
b 2.0 3.0
c NaN 4.0

Output of pd.show_versions()

[paste the output of pd.show_versions() here below this line]
INSTALLED VERSIONS

commit: None
python: 3.6.5.final.0
python-bits: 64
OS: Linux
OS-release: 4.15.0-51-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8

pandas: 0.24.2
pytest: 3.5.1
pip: 18.0
setuptools: 41.0.1
Cython: 0.28.2
numpy: 1.16.3
scipy: 1.2.1
pyarrow: None
xarray: None
IPython: 6.4.0
sphinx: 1.7.4
patsy: 0.5.0
dateutil: 2.8.0
pytz: 2019.1
blosc: None
bottleneck: 1.2.1
tables: 3.4.3
numexpr: 2.6.5
feather: None
matplotlib: 3.0.3
openpyxl: 2.5.3
xlrd: 1.2.0
xlwt: 1.3.0
xlsxwriter: 1.0.4
lxml.etree: 4.2.1
bs4: 4.6.0
html5lib: 1.0.1
sqlalchemy: 1.2.7
pymysql: 0.9.2
psycopg2: None
jinja2: 2.10
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None
gcsfs: None

@WillAyd
Copy link
Member

WillAyd commented Jun 27, 2019

Thanks for the report but closing as a duplicate of #21629

@WillAyd WillAyd added Duplicate Report Duplicate issue or pull request Reshaping Concat, Merge/Join, Stack/Unstack, Explode labels Jun 27, 2019
@WillAyd WillAyd closed this as completed Jun 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate Report Duplicate issue or pull request Reshaping Concat, Merge/Join, Stack/Unstack, Explode
Projects
None yet
Development

No branches or pull requests

2 participants