Skip to content

Extra empty row when saving to CSV with MultiIndex columns #13053

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

Closed
jluttine opened this issue May 2, 2016 · 1 comment
Closed

Extra empty row when saving to CSV with MultiIndex columns #13053

jluttine opened this issue May 2, 2016 · 1 comment

Comments

@jluttine
Copy link

jluttine commented May 2, 2016

If using MultiIndex as columns, saving to CSV adds an extra line with no data between the column headers and the data. I couldn't find information that this is something that should happen so it was unexpected to me.

Code Sample, a copy-pastable example if possible

In IPython:

import pandas as pd
pd.DataFrame({('a','b'): [1, 2], ('c','d'): [3, 4]}).to_csv('temp.csv', index=False)
cat temp.csv

Outputs:

a,c
b,d
,
1,3
2,4

Expected Output

I expected not to have an empty row between column names and the data:

a,c
b,d
1,3
2,4

output of pd.show_versions()

INSTALLED VERSIONS
------------------
commit: None
python: 3.5.1.final.0
python-bits: 64
OS: Linux
OS-release: 4.5.2-gnu-1
machine: x86_64
processor: 
byteorder: little
LC_ALL: None
LANG: en_DK.UTF-8

pandas: 0.18.0
nose: 1.3.7
pip: 8.1.1
setuptools: 20.10.1
Cython: 0.24
numpy: 1.11.0
scipy: 0.17.0
statsmodels: None
xarray: None
IPython: 4.2.0
sphinx: 1.4
patsy: None
dateutil: 2.5.3
pytz: 2016.4
blosc: None
bottleneck: None
tables: 3.2.2
numexpr: 2.5.2
matplotlib: 1.5.1
openpyxl: None
xlrd: 0.9.4
xlwt: None
xlsxwriter: None
lxml: None
bs4: 4.4.1
html5lib: None
httplib2: 0.9.2
apiclient: 1.5.0
sqlalchemy: 1.0.12
pymysql: None
psycopg2: 2.6.1 (dt dec pq3 ext lo64)
jinja2: 2.8
boto: None
@jluttine
Copy link
Author

jluttine commented May 2, 2016

Oh, duplicate of #6618 I think.

@jluttine jluttine closed this as completed May 2, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant