Puts objects into cells / columns of a Pandas Dataframe
Project description
Puts objects into cells / columns of a Pandas Dataframe
pip install a-pandas-ex-obj-into-cell
Not best (Pandas) practice, but sometimes very useful :)
from a_pandas_ex_obj_into_cell import pd_add_obj_into_cells
import pandas as pd
pd_add_obj_into_cells()
df = pd.read_csv(
"https://raw.githubusercontent.com/pandas-dev/pandas/main/doc/data/titanic.csv"
)
d1 = df.d_one_object_to_several_cells(
column="test1",
value=({1: ("xx", 331, 11)}),
indexlist=[1, 2, 3, 7],
ffill=True,
bfill=True,
)
print(d1)
d2 = df.d_list_items_to_cells(
column="test2",
values=[
[
1,
32,
4,
],
{33: "dfd", 0: [3, 2]},
4,
(5, 34),
],
indexlist=[1, 4, 6, 9],
ffill=False,
bfill=False,
)
print(d2)
'''
PassengerId Survived Pclass ... Cabin Embarked test1
0 1 0 3 ... NaN S {1: ('xx', 331, 11)}
1 2 1 1 ... C85 C {1: ('xx', 331, 11)}
2 3 1 3 ... NaN S {1: ('xx', 331, 11)}
3 4 1 1 ... C123 S {1: ('xx', 331, 11)}
4 5 0 3 ... NaN S {1: ('xx', 331, 11)}
.. ... ... ... ... ... ... ...
886 887 0 2 ... NaN S {1: ('xx', 331, 11)}
887 888 1 1 ... B42 S {1: ('xx', 331, 11)}
888 889 0 3 ... NaN S {1: ('xx', 331, 11)}
889 890 1 1 ... C148 C {1: ('xx', 331, 11)}
890 891 0 3 ... NaN Q {1: ('xx', 331, 11)}
[891 rows x 13 columns]
PassengerId Survived Pclass ... Cabin Embarked test2
0 1 0 3 ... NaN S <NA>
1 2 1 1 ... C85 C [1, 32, 4]
2 3 1 3 ... NaN S <NA>
3 4 1 1 ... C123 S <NA>
4 5 0 3 ... NaN S {33: 'dfd', 0: [3, 2]}
.. ... ... ... ... ... ... ...
886 887 0 2 ... NaN S NaN
887 888 1 1 ... B42 S NaN
888 889 0 3 ... NaN S NaN
889 890 1 1 ... C148 C NaN
890 891 0 3 ... NaN Q NaN
[891 rows x 13 columns]'''
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
File details
Details for the file a_pandas_ex_obj_into_cell-0.11.tar.gz
.
File metadata
- Download URL: a_pandas_ex_obj_into_cell-0.11.tar.gz
- Upload date:
- Size: 4.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0f0933b3e57b05f096f20b6b7cc17bb7d3538465c9f16f4cb7ee381af3d8ef56 |
|
MD5 | 1557c4a352069acb03bb8ed00aaf3fb7 |
|
BLAKE2b-256 | 27e2f396d445ebb1f6b32177d55b2108affffc98106738c41397d2cf464090b2 |
Provenance
File details
Details for the file a_pandas_ex_obj_into_cell-0.11-py3-none-any.whl
.
File metadata
- Download URL: a_pandas_ex_obj_into_cell-0.11-py3-none-any.whl
- Upload date:
- Size: 6.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2feb8f72b20a9ba89e14229cdf7b465a414a3557b33ad2bdaa2c7e870a10204f |
|
MD5 | 9b5d4150a9f9b3974826a1aa24ea3d1e |
|
BLAKE2b-256 | 78691e8d29048eb72c34e0371b3424ebc8d54ac3fccce88d528b1538e4a3705f |