Explode list/tuples in columns
Project description
Explode list/tuples in columns
pip install a-pandas-ex-horizontal-explode
from a_pandas_ex_horizontal_explode import pd_add_horizontal_explode
pd_add_horizontal_explode()
import pandas as pd
df = pd.Series(
[
("enabled_previews_v1", "type", 0),
("enabled_previews_v1", "version", 0),
True,
("enabled_previews_v1", "type", 0),
("enabled_previews_v1", 0),
("locale", 0),
("properties", "property_key", 0),
("properties", "property_value", 0),
("properties",),
("resume", "package_name", 0),
("resume", "stack", 0),
("resume", "timestamp", 0),
("resume", "external", 0),
("android_metadata", "locale", 0),
("android_metadata", "locale", 0),
("android_metadata", "locale", 0),
33,
("_sync_state", "_id", 0),
]
)
df2 = df.to_frame()
df2.columns=['aa']
dfex = df.ds_horizontal_explode(concat=True)
print(dfex.to_string())
dfex2 = df2.ds_horizontal_explode('aa',concat=False)
print(dfex2.to_string())
0 0_0 0_1 0_2
0 (enabled_previews_v1, type, 0) enabled_previews_v1 type 0
1 (enabled_previews_v1, version, 0) enabled_previews_v1 version 0
2 True <NA> <NA> <NA>
3 (enabled_previews_v1, type, 0) enabled_previews_v1 type 0
4 (enabled_previews_v1, 0) enabled_previews_v1 0 <NA>
5 (locale, 0) locale 0 <NA>
6 (properties, property_key, 0) properties property_key 0
7 (properties, property_value, 0) properties property_value 0
8 (properties,) properties <NA> <NA>
9 (resume, package_name, 0) resume package_name 0
10 (resume, stack, 0) resume stack 0
11 (resume, timestamp, 0) resume timestamp 0
12 (resume, external, 0) resume external 0
13 (android_metadata, locale, 0) android_metadata locale 0
14 (android_metadata, locale, 0) android_metadata locale 0
15 (android_metadata, locale, 0) android_metadata locale 0
16 33 <NA> <NA> <NA>
17 (_sync_state, _id, 0) _sync_state _id 0
aa_0 aa_1 aa_2
0 enabled_previews_v1 type 0
1 enabled_previews_v1 version 0
2 <NA> <NA> <NA>
3 enabled_previews_v1 type 0
4 enabled_previews_v1 0 <NA>
5 locale 0 <NA>
6 properties property_key 0
7 properties property_value 0
8 properties <NA> <NA>
9 resume package_name 0
10 resume stack 0
11 resume timestamp 0
12 resume external 0
13 android_metadata locale 0
14 android_metadata locale 0
15 android_metadata locale 0
16 <NA> <NA> <NA>
17 _sync_state _id 0
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
Built Distribution
Close
Hashes for a_pandas_ex_horizontal_explode-0.10.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 61bf54dbd8a796e293e9abed1350a5c80efd83f609110d325c541022c1b99dae |
|
MD5 | b825565b91d7595040cff4468fbd45c0 |
|
BLAKE2b-256 | 092f5b1533c685d21d968cd7fa96d1fe6e2d4d4ad92ed86b9ecc285ee5446f7f |
Close
Hashes for a_pandas_ex_horizontal_explode-0.10-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 19d4eb122b765dcdb47cba375f2b95e7cfe174145891aca3b8678a020e1d2933 |
|
MD5 | 5a62e125543ec297f80bc22b209d4226 |
|
BLAKE2b-256 | adab748aa645a5687ad69ec5f5c473c65ef48053c764f8a01885f5d08ee3fe0c |