Skip to content

Commit

Permalink
Try to keep the original column types
Browse files Browse the repository at this point in the history
  • Loading branch information
bra-fsn committed Apr 11, 2022
1 parent 21c1917 commit ead74de
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions hashable_df/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,15 @@ def f(value):

def hashable_df(df):
"""Return a DataFrame with hashable cell values."""
return df.applymap(f)
# applymap might change types. Try to restore the original.
orig_types = df.dtypes
df = df.applymap(f).astype(orig_types, errors="ignore")
return df


def hashable_series(ser):
"""Return a Series with hashable values."""
return ser.map(f)


__version__ = '0.0.6'
__version__ = '0.0.7'

0 comments on commit ead74de

Please sign in to comment.