ipydfconfig
ipydfconfig is an IPython extension to simplify per-cell dataframe display configuration.
Quickstart
pip install ipydfconfig- In a notebook or IPython session,
%load_ext ipydfconfig
- For any cell in which you wish to temporarily configure a dataframe output, for polars,
%%plconfig nr=20 df
or for pandas,%%pdconfig nc=50 strlen=200 df
Motivation
In IPython and more commonly, Jupyter notebooks using the IPython kernel, if you wish to display a specific dataframe with more rows or columns than the default, you generally have two imperfect solutions:
Imperfect Solution 1: Modify the global configuration
pl.Config.set_tbl_rows(20)
df
pd.set_option('display.max_rows', 20)
df
The downside to this solution is that these options persist for the entire session unless you execute code to reset them, meaning they are not constrained to a particular cell.
Imperfect Solution 2: Use a context manager with display
with pl.Config(tbl_rows=20):
display(df)
with pd.option_context('display.max_rows', 20):
display(df)
While this solution ensures the changes are only for the specified block of code, the edits signficantly alter
the structure of the code, and IPython no longer considers df as the "output" of the cell.
Configuration Option Confusion
Finally, if you use multiple dataframe modules, the differences between configuration options
can require consulting documentation and/or lengthy parameter names (e.g. display.max_rows in pandas vs. tbl_rows in polars).
ipydfconfig
ipydfconfig simplifies this process by introducing cell magics that configure a cell according to the specified
options that only apply to that single cell. In addition, users can use universal shortcuts that will be translated
to whichever dataframe library is being used. Finally, the %%dfconfig cell magic will apply to outputs from any
configured dataframe module; if an option is specific to one module, it will be ignored for the others.
There are three cell magics:
%%plconfig: polars%%pdconfig: pandas%%dfconfig: universal
In addition to all specified option names from each library (polars docs, pandas docs), ipydfconfig provides the following shortcuts that are translated to the equivalent option names:
nr: number of rows to displayrows: number of rows to displaync: number of columns to displaycols: number of columns to displaystrlen: maximum number of characters to show per stringlistlen: maximum number of items to show in a list/sequence
Examples
polars
%%plconfig nr=20
df
pandas
%%pdconfig nc=50 strlen=200
df
universal
df1 = pd.read_parquet('data.parquet')
display(df1)
df2 = pl.read_parquet('data.parquet')
display(df2)
Metadata
Release files for ipydfconfig 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| ipydfconfig-0.1.2.tar.gz | 5.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ipydfconfig-0.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 10.2 kB
Release files / ipydfconfig-0.1.2.tar.gz
| Download URL | ipydfconfig-0.1.2.tar.gz |
|---|---|
| Size | 5.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7d0de2f9807cccf12d2b80a66a94e7165e954df8ca9e4a8a50813d02ca2c7960
|
|
BLAKE2b-256 checksum How to use checksums |
e158827a91b5534528928a32c6e5f31dd9b84a072ceea155b14ca8546d587e5a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Release files / ipydfconfig-0.1.2-py3-none-any.whl
| Download URL | ipydfconfig-0.1.2-py3-none-any.whl |
|---|---|
| Size | 5.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
67b8f86a6c14472d2a34e8a90f5c933220b6ad4040ea6b4effb75bb59727c2c0
|
|
BLAKE2b-256 checksum How to use checksums |
d4994f81605f05d74cc9f228b51e7766637cafb3977fc48a2d869f685a1cd78f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|