No project description provided
Project description
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)
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 ipydfconfig-0.1.1.tar.gz.
File metadata
- Download URL: ipydfconfig-0.1.1.tar.gz
- Upload date:
- Size: 5.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d43a61a073b58f6d782ee3f4d47f1ff7cb209366316afbbe8ca077ed954053ab
|
|
| MD5 |
8bc65f0ce90e3c89f9b151d7dcdbe7d3
|
|
| BLAKE2b-256 |
98431f60f44ecb30dd3ac80bc97299fba065630545593f155a2c32ed02f541da
|
File details
Details for the file ipydfconfig-0.1.1-py3-none-any.whl.
File metadata
- Download URL: ipydfconfig-0.1.1-py3-none-any.whl
- Upload date:
- Size: 5.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3af313e630ba9d97e34e4f1dcb6220c793388603e756ec2ca0bee8f77f8ea602
|
|
| MD5 |
9521649a2523aaa849231ef56187c740
|
|
| BLAKE2b-256 |
1daf49f0cee43efeb019393612147f98d6833a4aae2c7add4bfddfbdb6f26308
|