Makes unhashable values in a pandas DataFrame hashable
Project description
hashable_df
If you have ever tried to use native python objects in Pandas DataFrames, you may have run into an issue similar to this:
df = pd.DataFrame({"A": [1, 2, 3, 4],
"B": ["a", "b", "c", "d"],
"C": [[1, 2, 3], [1, 2], [1, 2, 3], 4],
"D": [{1: 1, 2: 2}, {1: 1, 3: 3}, {1: 1, 4: 4}, {1: 1, 2: 2}],
"E": [[{1: {2: 2}}, {2: {3: 3}}], [{1: {2: 2}}, {2: {3: 3}}],
[{1: {2: 2}}, {2: {3: 3}}], [{1: {2: 2}}, {2: {3: 3}}]]
})
df['C'].unique()
TypeError: unhashable type: 'list'
This is caused by unhashable values in the DataFrame cells.
This small library helps to resolve that making this possible:
from hashable_df import hashable_df
hashable_df(df)['E'].unique()
returning
array([[{1: {2: 2}}, {2: {3: 3}}]], dtype=object)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
hashable_df-0.0.4.tar.gz
(1.9 kB
view hashes)
Built Distribution
Close
Hashes for hashable_df-0.0.4-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3e3ed8f8e0530794b6efd5ec859c8fc2f7bb20a33fa07f6067265f39a8844cda |
|
MD5 | 2b5f9f0cd374590f7199d0e29baa4c2e |
|
BLAKE2b-256 | d80029bb6572b863b57327b4ec493d0567dbc4170b280251e917eee4d6424cef |