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

to_string formatters not as expected when header=False #16839

Closed
adamboche opened this issue Jul 6, 2017 · 1 comment

Comments

Projects
None yet
2 participants
@adamboche
Copy link

commented Jul 6, 2017

Code Sample, a copy-pastable example if possible

import pandas
df = pandas.DataFrame({'c': 1, 'd': 2.3}, index=[0], )
formats = {'c': '{: 10d}', 'd': '{: 2.5f}'}
formatters = {k: v.format for k, v in formats.items()}
print(df.to_string(formatters=formatters, index=False, header=True))
print(df.to_string(formatters=formatters, index=False, header=False))

Problem description

I expect the spaces in the beginning, but they don't appear when header=False.

u'c        d\n        1  2.30000'
'1  2.30000'

Expected Output

u'c        d\n        1  2.30000'
'         1  2.30000'

Output of pd.show_versions()

# Paste the output here pd.show_versions() here INSTALLED VERSIONS ------------------ commit: None python: 2.7.12.final.0 python-bits: 64 OS: Linux OS-release: 4.8.0-58-generic machine: x86_64 processor: x86_64 byteorder: little LC_ALL: None LANG: en_US.UTF-8 LOCALE: None.None

pandas: 0.20.2
pytest: 3.1.2
pip: 9.0.1
setuptools: 36.0.1
Cython: None
numpy: 1.13.0
scipy: None
xarray: None
IPython: 5.4.1
sphinx: None
patsy: None
dateutil: 2.6.0
pytz: 2017.2
blosc: None
bottleneck: None
tables: None
numexpr: None
feather: None
matplotlib: None
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: 0.999999999
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: 2.9.6
s3fs: None
pandas_gbq: None
pandas_datareader: None

@jreback

This comment has been minimized.

Copy link
Contributor

commented Jul 6, 2017

looks realted to #13032 ? can you have a look.

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