Skip to content

BUG: inconsistent spacing in df.info() #36765

Closed
@ivanovmg

Description

@ivanovmg
  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pandas.

  • (optional) I have confirmed this bug exists on the master branch of pandas.


Note: Please read this guide detailing how to provide the necessary information for us to reproduce your bug.

Code Sample, a copy-pastable example

See that the spacing between all columns is 2 spaces. Even if there is a long string in Non-Null Count column.

df = pd.DataFrame({'long long column': np.random.rand(1000000)})
df.info()
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 1000000 entries, 0 to 999999
Data columns (total 1 columns):
 #   Column            Non-Null Count    Dtype
---  ------            --------------    -----
 0   long long column  1000000 non-null  float64
dtypes: float64(1)
memory usage: 7.6 MB

Note that there is only one space between # and Column columns when the number of columns is over 1000 (last line of tail).

import pandas as pd
import numpy as np
df = pd.DataFrame(np.random.rand(3, 10001))
with open('out.txt', 'w') as buf:
    df.info(verbose=True, buf=buf)
$ tail out.txt
 9993  9993    float64
 9994  9994    float64
 9995  9995    float64
 9996  9996    float64
 9997  9997    float64
 9998  9998    float64
 9999  9999    float64
 10000 10000   float64
dtypes: float64(10001)
memory usage: 234.5 KB

Problem description

I find inconsistent behavior in spacing between columns in the output df.info() when dealing with dataframes having over 1000 columns.

Expected Output

Expect to have two spaces distance between all columns regardless of the col widths.

Output of pd.show_versions()

INSTALLED VERSIONS

commit : f6ccbbc
python : 3.7.7.final.0
python-bits : 64
OS : Linux
OS-release : 4.19.76-linuxkit
Version : #1 SMP Tue May 26 11:42:35 UTC 2020
machine : x86_64
processor :
byteorder : little
LC_ALL : C.UTF-8
LANG : C.UTF-8
LOCALE : en_US.UTF-8

pandas : 1.2.0.dev0+559.gf6ccbbc1e.dirty
numpy : 1.18.5
pytz : 2020.1
dateutil : 2.8.1
pip : 20.2.1
setuptools : 45.2.0.post20200210
Cython : 0.29.21
pytest : 6.0.1
hypothesis : 5.23.11
sphinx : 3.1.1
blosc : None
feather : None
xlsxwriter : 1.3.1
lxml.etree : 4.4.1
html5lib : 1.1
pymysql : None
psycopg2 : None
jinja2 : 2.11.2
IPython : 7.17.0
pandas_datareader: None
bs4 : 4.9.1
bottleneck : 1.3.2
fsspec : 0.8.0
fastparquet : 0.4.1
gcsfs : 0.6.2
matplotlib : 3.2.1
numexpr : 2.7.1
odfpy : None
openpyxl : 3.0.4
pandas_gbq : None
pyarrow : 0.16.0
pytables : None
pyxlsb : None
s3fs : 0.4.2
scipy : 1.5.2
sqlalchemy : 1.3.18
tables : 3.6.1
tabulate : 0.8.7
xarray : 0.16.0
xlrd : 1.2.0
xlwt : 1.3.0
numba : 0.50.1

Metadata

Metadata

Assignees

Labels

BugIO DataIO issues that don't fit into a more specific labelNeeds TriageIssue that has not been reviewed by a pandas team member

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions