1

Ok so after seeing and experiencing a lot of performance comparison between Pandas and Polars, I'm convinced to move to Polars.

The thing is that when using Spyder IDE to print the DataFrames, the following happens:

  • In Pandas the DataFrame conveniently breaks down into new lines when there are many columns - 1st image below.
  • In Polars the DataFrame starts to mess up when there are many columns - 2nd image below.

After a lot of search I guess Spyder IPython's Console does not offer a horizontal scroll bar, and Polars Config.set_* methods don't have a specific method to handle print options.

Considering that I need to print these many columns and resizing the Spyder's panes to the right/left of the interface by placing the mouse on the vertical separator is not enought, is there any workaround?

Codes:

import pandas as pd
import polars as pl


df_pd = pd.DataFrame(
    {
        'Extensive_Column_Name_01': [i for i in range(10)],
        'Extensive_Column_Name_02': [i for i in range(10)],
        'Extensive_Column_Name_03': [i for i in range(10)],
        'Extensive_Column_Name_04': [i for i in range(10)],
        'Extensive_Column_Name_05': [i for i in range(10)]
    }    
        
)

print(df_pd)


df_pl = pl.DataFrame(
    {
        'Extensive_Column_Name_01': [i for i in range(10)],
        'Extensive_Column_Name_02': [i for i in range(10)],
        'Extensive_Column_Name_03': [i for i in range(10)],
        'Extensive_Column_Name_04': [i for i in range(10)],
        'Extensive_Column_Name_05': [i for i in range(10)]
    }    
        
)

print(df_pl)

enter image description here

enter image description here

Danilo Setton
  • 601
  • 10
  • 20
  • 1
    I believe `display.expand_frame_repr` is the pandas option that does this. https://stackoverflow.com/q/75786523 - https://github.com/pola-rs/polars/issues/7665 - The table repr has just been updated https://github.com/pola-rs/polars/commit/4b0218cf22b9d8cdaefa71662baf26888a132be6 which should improve things. Perhaps the new comfy-table update also allows for an implementation of an `expand_frame_repr` equivalent. You may need to ask on the issues tracker. – jqurious Jul 08 '23 at 04:05

0 Answers0