pandas_explode
author: Oren Ovadia
Overview
Explode utility for Pandas dataframes (similar to UNNEST or explode)
Examples
import pandas as pd
import pandas_explode
pandas_explode.patch() # adds a `df.explode` method to all DataFrames
df = pd.DataFrame({'s': ['a', 'b', 'c'], 'values': [[1, 2], [3, 4, 5], []]})
df
# s values
# 0 a [1, 2]
# 1 b [3, 4, 5]
# 2 c []
df.explode('values')
# s values
# 0 a 1
# 0 a 2
# 1 b 3
# 1 b 4
# 1 b 5
df = pd.DataFrame({'s': ['a', 'b', 'c'], 'values': [{'col1': 1, 'col2': 2}, {'col1': 10, 'col3': 20}, {'col2': 2}]})
df
# s values
# 0 a {'col1': 1, 'col2': 2}
# 1 b {'col1': 10, 'col3': 20}
# 2 c {'col2': 2}
df.explode('values', axis=1)
# s col1 col2 col3
# 0 a 1.0 2.0 NaN
# 1 b 10.0 NaN 20.0
# 2 c NaN 2.0 NaN
df.explode('values', axis=1, record_prefix=True)
# s values.col1 values.col2 values.col3
# 0 a 1.0 2.0 NaN
# 1 b 10.0 NaN 20.0
# 2 c NaN 2.0 NaN
Installation / Usage
To install use pip:
$ pip install pandas_explode
Or clone the repo:
$ git clone https://github.com/orenovadia/pandas_explode.git
$ python setup.py install
Publishing
$ ./publish.sh
Metadata
Release files for pandas-explode 0.0.7
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_explode-0.0.7.tar.gz | 4.0 kB | Without provenance | Details for pandas_explode-0.0.7.tar.gz |
Release files / pandas_explode-0.0.7.tar.gz
| Download URL | pandas_explode-0.0.7.tar.gz |
|---|---|
| Size | 4.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
54142f3fe4305951598f110f2c36306574d934fb6124eb305a24db2a49f70521
|
|
BLAKE2b-256 checksum How to use checksums |
0cb9979555fcb95a2396c8a61ff92e87c7030320c24a62fc4af28d5512cf9669
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.9
|
Security for pandas-explode 0.0.7
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.