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:
korUp Arrow Keyto scroll upjorDown Arrow Keyto scroll downhorLeft Arrow Keyto scroll leftlorRight Arrow Keyto scroll rightenterto select a rowqto 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_color='Gray')
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. Pressenterto 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
RedBlueMagentaGray
Project details
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 termpandas-0.2.3.tar.gz.
File metadata
- Download URL: termpandas-0.2.3.tar.gz
- Upload date:
- Size: 7.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e5eeb9ebf72d61742112667f40d6bac5eb54b8956db86eed37a62167ccccaf80
|
|
| MD5 |
0eec8edc8052487df622943535561842
|
|
| BLAKE2b-256 |
5d6cf1e7e95ff03208faff4d6ad0ba4131a7c4b03a6bdc1bd18af183db876574
|
File details
Details for the file termpandas-0.2.3-py3-none-any.whl.
File metadata
- Download URL: termpandas-0.2.3-py3-none-any.whl
- Upload date:
- Size: 5.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ba6959852f1713fab75405cee33d14d644815fd0ae6b9bfc57ad0f83850400f6
|
|
| MD5 |
ff92e7ba474bdab94392fe3263e8c32f
|
|
| BLAKE2b-256 |
de1a878c2f673a9c593631a00a2538988c9bb70afda7ce5cc44c1540762fdb76
|