A tiny helper to print clean, readable info summaries for Polars DataFrames.
Project description
polars-info
Pandas-like df.info() for Polars.
Polars has no built-in .info(). This library brings the familiar summary view
to polars.DataFrame — column dtypes, null counts, memory usage — just like
pandas.DataFrame.info(), plus extras like head/tail column truncation.
With print_df_info(), you can print a clean, friendly summary of:
- shape (rows and columns)
- estimated size (bytes)
- per-column dtypes
- null / non-null stats (optional)
- sample rows from the head (optional)
Even when your table has tons of columns, head + tail display keeps it readable.
✏️ Pandas df.info() vs polars_info
Pandas df.info() |
polars-info print_df_info(df) |
|---|---|
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 3 entries, 0 to 2
Data columns (total 3 columns):
# Column Non-Null Count Dtype
--- ------ -------------- -----
0 id 3 non-null int64
1 name 2 non-null object
2 score 2 non-null float64
dtypes: float64(1), int64(1), object(1)
memory usage: 200.0+ bytes
|
<class 'polars.dataframe.frame.DataFrame'>
Shape: (3, 3)
Estimated size: 51 B
Columns:
# Column Dtype Non-Null Null Null%
0 id Int64 3 0 0.00%
1 name String 2 1 33.33%
2 score Float64 2 1 33.33%
|
Key differences from Pandas:
- Null% column — instantly spot columns with high missing rates
- Head/tail truncation — DataFrames with 100+ columns stay readable
- Returns a summary object —
DFInfoSummaryfor programmatic use
📦 Install
pip install polars-info
🚀 Quick Start
import polars as pl
from polars_info import print_df_info
df = pl.DataFrame(
{
"id": [1, 2, 3],
"name": ["A", "B", None],
"score": [10.2, None, 8.7],
}
)
summary = print_df_info(df)
<class 'polars.dataframe.frame.DataFrame'>
Shape: (3, 3)
Estimated size: 51 B
Columns:
# Column Dtype Non-Null Null Null%
0 id Int64 3 0 0.00%
1 name String 2 1 33.33%
2 score Float64 2 1 33.33%
Use name and show_sample to add a label and preview rows.
summary = print_df_info(df, name="demo_df", show_sample=2)
<class 'polars.dataframe.frame.DataFrame'>
Name: demo_df
Shape: (3, 3)
Estimated size: 51 B
Columns:
# Column Dtype Non-Null Null Null%
0 id Int64 3 0 0.00%
1 name String 2 1 33.33%
2 score Float64 2 1 33.33%
Sample (head 2):
shape: (2, 3)
┌─────┬──────┬───────┐
│ id ┆ name ┆ score │
│ --- ┆ --- ┆ --- │
│ i64 ┆ str ┆ f64 │
╞═════╪══════╪═══════╡
│ 1 ┆ A ┆ 10.2 │
│ 2 ┆ B ┆ null │
└─────┴──────┴───────┘
The returned DFInfoSummary gives you programmatic access to the metadata.
print(summary.rows, summary.cols) # 3 3
print(summary.dtypes) # {'id': Int64, 'name': String, 'score': Float64}
🌟 Great For
- fixing "too many columns, can't read anything" in notebooks
- quickly checking dtype / null health before preprocessing
- running lightweight, repeatable data sanity checks
⚙️ Main Options
print_df_info(
df,
name="train_df",
display="auto", # "auto" | "head_tail" | "full"
head=5, # head columns shown in head_tail mode
tail=5, # tail columns shown in head_tail mode
max_cols=60, # full-display limit in auto/full mode
show_null_stats=True,
show_sample=3, # print first 3 rows
)
📄 License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file polars_info-0.1.0.tar.gz.
File metadata
- Download URL: polars_info-0.1.0.tar.gz
- Upload date:
- Size: 5.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
59e5396047a59bd561b88d6d707d0fac6ca6fa723ed60858c0edf87cff17526c
|
|
| MD5 |
b1329d2e5f284e1eb6bc12309e5f0d1d
|
|
| BLAKE2b-256 |
5605d962ab935796a59730d846de5bf2b30ad96a436dd9ca403615ef2ad1c2ac
|
File details
Details for the file polars_info-0.1.0-py3-none-any.whl.
File metadata
- Download URL: polars_info-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
12b8061de8b4ca81602d651d542e3e3c6d0f6d4c155b2ca1051d1082fea8fa4d
|
|
| MD5 |
2b9a39488d2cdbce45907cb0e6b30a26
|
|
| BLAKE2b-256 |
28abd49570f98ea0904b76819940edd846c5caa83c9ebc32d8d57149512a535f
|