Scrollable pandas dataframes in the terminal.
Project description
termpandas
Scrollable Pandas and Polars DataFrames in the Terminal.
Installation
pip install termpandas
Note: This library is not compatible with Windows at the moment.
Basic Usage
import pandas as pd
from termpandas import tprint
df = pd.read_csv('titanic.csv')
tprint(df)
- Key Bindings:
k
orUp Arrow Key
to scroll upj
orDown Arrow Key
to scroll downh
orLeft Arrow Key
to scroll leftl
orRight Arrow Key
to scroll rightenter
to select a rowq
to quit
Parameters
num_rows
: Number of rows to display at a time. Default is 10.
tprint(df, num_rows=5)
highlight
: Highlights the selected row. Default isTrue
.
tprint(df, highlight=True)
highlight_color
: Color of the selected row. Default isGray
.
tprint(df, highlight=True)
masks
: Dictionary of masks to highlight rows. Default is{}
. The keys are the colors and the values are the masks.
mask_1 = df['Survived'] == 1
mask_2 = df['Sex'] == 'male'
tprint(df.head(20), masks={'Red': mask_1,'Blue': mask_2})
return_row
: Returns the selected row. Default isFalse
. Pressenter
to select a row.
result = tprint(df.head(20), return_row=True)
try:
tprint(result)
except:
print("Quit termpandas: No row selected")
Polars Support
-
Note: Masks are not currently supported for Polars DataFrames. Convert to pandas DataFrames to utilize masks functionality.
-
Returning Selected Row is supported and works just like with Pandas DataFrames.
import polars as pl
from termpandas import tprint
# DataFrame needs to be collected
df = pl.scan_csv('titanic.csv').collect()
tprint(df)
Available Colors
Red
Blue
Magenta
Gray
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
termpandas-0.2.2.tar.gz
(7.2 kB
view hashes)
Built Distribution
Close
Hashes for termpandas-0.2.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | babca2a5282994d3995138672cb4b5181f73ce5bfb8f49402c954e9d36914fc1 |
|
MD5 | e2c5b8a841eddceb0d10ac2af021e6b3 |
|
BLAKE2b-256 | 08782bd1ad7fb325bdc9aefe0cd4aa7b0fc2ead283cf8881f2eb86013800c635 |