New methods for pandas DataFrame and Series.
Project description
pdpatch
pdpatch
adds methods to pandas’
DataFrame
and Series
for a faster data science pipeline. It also
defines drop-in replacements for seaborn
and plotly.express
that
automatically label axes with nicer titles. We use
nbdev to build this project.
Install
pip install pdpatch
How to use
from pdpatch.all import *
Interactive Method .less()
Automatically Rename snake_case columns in plotly.express
and seaborn
import pandas as pd
from pdpatch.express import *
df = pd.DataFrame({'time__s__': range(10), 'position__m__': [i**1.3 for i in range(10)], 'speed__m/s__': 10*[1]})
#df = pd.DataFrame({'time__s__': range(10), 'position__m__': range(10)})
px.scatter(df, x='time__s__', y='position__m__').show('png')
from pdpatch.seaborn import sns
sns.scatterplot(data=df, x='time__s__', y='position__m__');
Add Altair-like Operation to plotly Figures
fig = px.scatter(df,x='time__s__', y='time__s__') | px.scatter(df,x='time__s__', y=['position__m__', 'speed__m/s__'])
fig
Unable to display output for mime type(s): application/vnd.plotly.v1+json
fig = px.scatter(df,x='time__s__', y='time__s__') / px.scatter(df,x='time__s__', y=['position__m__', 'speed__m/s__'])
fig
Unable to display output for mime type(s): application/vnd.plotly.v1+json
fig = px.scatter(df,x='time__s__', y='time__s__') | px.scatter(df,x='time__s__', y=['position__m__', 'speed__m/s__'])
fig / fig
Unable to display output for mime type(s): application/vnd.plotly.v1+json
Shorter methods
df.rename(columns={'col_1': 'new_name'})
->df.renamec('col_1', 'new_name')
df = dummydf()
df.renamec('col_1', 'new_name').to_html()
new_name | col_2 | |
---|---|---|
0 | 100 | a |
1 | 101 | b |
2 | 102 | c |
3 | 103 | d |
4 | 104 | e |
Functions as methods
df.len()
5
New methods
df.col_1.minmax
(100, 104)
Utility functions
df = dummydf()
df.to_html()
col_1 | col_2 | |
---|---|---|
0 | 100 | a |
1 | 101 | b |
2 | 102 | c |
3 | 103 | d |
4 | 104 | e |
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
pdpatch-0.1.8.tar.gz
(13.9 kB
view details)
Built Distribution
pdpatch-0.1.8-py3-none-any.whl
(12.8 kB
view details)
File details
Details for the file pdpatch-0.1.8.tar.gz
.
File metadata
- Download URL: pdpatch-0.1.8.tar.gz
- Upload date:
- Size: 13.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8028b723056c8e30d1093201be21a40e70c781d47af22d49e6846d6bc4c264f9 |
|
MD5 | a1ae7823b3dd6c9ed4a762aa7f763090 |
|
BLAKE2b-256 | 03fe710dfdf7d5033aee58f7cdf7db917e290fbb0f377c9172917a94a614e8a9 |
File details
Details for the file pdpatch-0.1.8-py3-none-any.whl
.
File metadata
- Download URL: pdpatch-0.1.8-py3-none-any.whl
- Upload date:
- Size: 12.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | eb81ccf7d5ae0070704e9330f20a1d1ea2edab19373a3bd6b85f8fc39be49f35 |
|
MD5 | 2fce15401ac7669fc88d014feb6288c6 |
|
BLAKE2b-256 | c6f9535d8ece1f97bf0313a1f6a93204adc88f51c16ddf9a2a04b8a8e0f2c399 |