Search code examples
pythonpandasdebuggingpython-polarstruncated

Polars / Python Limits Number of Printed Table Output Rows


Does anyone know why polars (or maybe my pycharm setup or python debugger) limits the number of rows in the output? This drives me nuts.

Here is the polars code i am running but I do suspect its not polars specific as there isnt much out there on google (and chatgpt said its info is too old haha).

import polars as pl

df = pl.scan_parquet('/path/to/file.parquet')
result_df =(
        df
        .filter(pl.col("condition_category") == 'unknown')
        .groupby("type")
        .agg(
            [
                pl.col("type").count().alias("counts"),
            ]
        )
    ).collect()
print(result_df)

polars printout of query result


Solution

  • Looks like the following will work. Thanks to @wayoshi for sharing this. I will say that the defaults are way too conservative!

    with pl.Config(tbl_rows=1000):
        print(result_df)
    

    or throw this at the top of your script if you prefer to not manage contexts.

    import polars as pl
    
    # Configure Polars 
    cfg = pl.Config()
    cfg.set_tbl_rows(2000)