-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
bra@fsn.hu
committed
May 29, 2020
1 parent
0295835
commit e76f7cc
Showing
1 changed file
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,31 @@ | ||
# 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: | ||
|
||
```python | ||
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: | ||
|
||
```python | ||
from hashable_df import hashable_df | ||
hashable_df(df)['E'].unique() | ||
``` | ||
|
||
returning | ||
``` | ||
hashable_df(df)['E'].unique() | ||
``` |