Purpose
- a collection of pandas DataFrame methods and functions I commonly used decorated with scikit-lego's
@log_stepto enable logging within method chaining - Wanted to use the logging of common pandas methods across projects
- Inspired from Vincent D. Warmerdam's PyData Eindhoven 2019 talk titled Untitled12.ipynb
- See the docs for pandas pipelines of scikit-lego to view the general use case for
@log_step - See
examples/demo.ipynbfor a few workflows and links to other relevant SE questions
In [1]: import pandas as pd; import numpy as np; import logging
In [2]: import pandas_pipe
In [3]: stream_handler = logging.StreamHandler()
In [4]: pandas_pipe.logger.addHandler(stream_handler)
In [5]: dataf_input = pd.DataFrame(
...: {
...: "aaa": {0: 10, 1: 11, 2: 12, 3: 13},
...: "myid": {0: 1, 1: 2, 2: 3, 3: 4},
...: "num": {0: "1, 2, 3", 1: np.nan, 2: "1, 2", 3: np.nan},
...: "text": {0: "aa, bb, cc", 1: np.nan, 2: "cc, dd", 3: "ee"},
...: "states": {
...: 0: "Wyoming; Illinois; New Hampshire",
...: 1: "Pennsylvania",
...: 2: "New York",
...: 3: "Pennsylvania",
...: },
...: }
...: )
In [6]: dataf_input
Out[6]:
aaa myid num text states
0 10 1 1, 2, 3 aa, bb, cc Wyoming; Illinois; New Hampshire
1 11 2 NaN NaN Pennsylvania
2 12 3 1, 2 cc, dd New York
3 13 4 NaN ee Pennsylvania
In [7]: (
...: dataf_input.pipe(pandas_pipe.start_pipeline)
...: .pipe(pandas_pipe.explode_setup, columns=["num", "text"], delimiter=",")
...: .pipe(pandas_pipe.explode_setup, columns=["states"], delimiter=";")
...: .pipe(pandas_pipe.explode, column="num", ignore_index=False)
...: .pipe(pandas_pipe.explode, column="text", ignore_index=False)
...: .pipe(pandas_pipe.explode, column="states", ignore_index=False)
...: .pipe(pandas_pipe.drop_duplicates)
...: )
[start_pipeline(df)] time=0:00:00.000152 n_obs=4, n_col=5 names=['aaa', 'myid', 'num', 'text', 'states']
[explode_setup(df, columns = ['num', 'text'], delimiter = ',')] time=0:00:00.001107 n_obs=4, n_col=5 delta=(0, 0)
[explode_setup(df, columns = ['states'], delimiter = ';')] time=0:00:00.000466 n_obs=4, n_col=5 delta=(0, 0)
[explode(df, column = 'num', ignore_index = False)] time=0:00:00.003697 n_obs=7, n_col=5 delta=(+3, 0)
[explode(df, column = 'text', ignore_index = False)] time=0:00:00.002642 n_obs=15, n_col=5 delta=(+8, 0)
[explode(df, column = 'states', ignore_index = False)] time=0:00:00.002184 n_obs=33, n_col=5 delta=(+18, 0)
[drop_duplicates(df)] time=0:00:00.001671 n_obs=33, n_col=5 delta=(0, 0)
Out[7]:
aaa myid num text states
0 10 1 1 aa Wyoming
0 10 1 1 aa Illinois
0 10 1 1 aa New Hampshire
0 10 1 1 bb Wyoming
0 10 1 1 bb Illinois
0 10 1 1 bb New Hampshire
0 10 1 1 cc Wyoming
0 10 1 1 cc Illinois
0 10 1 1 cc New Hampshire
0 10 1 2 aa Wyoming
0 10 1 2 aa Illinois
0 10 1 2 aa New Hampshire
0 10 1 2 bb Wyoming
0 10 1 2 bb Illinois
0 10 1 2 bb New Hampshire
0 10 1 2 cc Wyoming
0 10 1 2 cc Illinois
0 10 1 2 cc New Hampshire
0 10 1 3 aa Wyoming
0 10 1 3 aa Illinois
0 10 1 3 aa New Hampshire
0 10 1 3 bb Wyoming
0 10 1 3 bb Illinois
0 10 1 3 bb New Hampshire
0 10 1 3 cc Wyoming
0 10 1 3 cc Illinois
0 10 1 3 cc New Hampshire
1 11 2 NaN NaN Pennsylvania
2 12 3 1 cc New York
2 12 3 1 dd New York
2 12 3 2 cc New York
2 12 3 2 dd New York
3 13 4 NaN ee Pennsylvania
Metadata
Release files for pandas-pipe 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pandas_pipe-0.0.1.tar.gz | 5.2 kB | Without provenance | Details for pandas_pipe-0.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pandas_pipe-0.0.1-py3-none-any.whl | Python 3 | none | any | Details for pandas_pipe-0.0.1-py3-none-any.whl |
Total release size: 10.2 kB
Release files / pandas_pipe-0.0.1.tar.gz
| Download URL | pandas_pipe-0.0.1.tar.gz |
|---|---|
| Size | 5.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
13d87dbf4bd5e7bbdde7de9b2573a6d85018519f154d17d5c6fa7e5a863b4c24
|
|
BLAKE2b-256 checksum How to use checksums |
a5bc66fc02d6ba725b265e455d01307dbeefb374772e35af6469d4bc01c08048
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.5 CPython/3.7.3 Darwin/18.7.0
|
Release files / pandas_pipe-0.0.1-py3-none-any.whl
| Download URL | pandas_pipe-0.0.1-py3-none-any.whl |
|---|---|
| Size | 5.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c29f2766e3823667f08f961d59a09db9e4d90dc7b1548151361a4aa7b1ebfaa7
|
|
BLAKE2b-256 checksum How to use checksums |
98a2ba9ab6b05496c1bfaaa1b2274c12621dfbe23b46b586853fcbf832fe806f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.5 CPython/3.7.3 Darwin/18.7.0
|
Security for pandas-pipe 0.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.