Skip to content

BUG: too much whitespace in truncated DataFrame repr leads to line overflow #24849

Closed
@jorisvandenbossche

Description

@jorisvandenbossche

Example case from #22524 (comment) where the default repr is doing something wrong:

In [8]: import geopandas 
   ...: world = geopandas.read_file(geopandas.datasets.get_path('naturalearth_lowres')) 

In [9]: pd.options.display.max_columns = 0   # default

In [17]: world.head()                                                           
Out[17]: 
      pop_est                        ...                                                         
          geometry
0  28400000.0                        ...                          POLYGON ((61.2
1081709172574 35.65007233330923,...
1  12799293.0                        ...                          (POLYGON ((16.
32652835456705 -5.87747039146621...
2   3639453.0                        ...                          POLYGON ((20.5
9024743010491 41.85540416113361,...
3   4798491.0                        ...                          POLYGON ((51.5
7951867046327 24.24549713795111,...
4  40913584.0                        ...                          (POLYGON ((-65
.50000000000003 -55.199999999999...

[5 rows x 6 columns]

So it detects (probably correctly) that is can only show two columns in the current console width, but, then it adds so much white space between the two columns that it ends up being too wide. This results in an overflow of the lines, giving this very strange (and unclear) repr.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions