Skip to content

Commit

Permalink
fix: charset problem
Browse files Browse the repository at this point in the history
  • Loading branch information
danielamguerra committed May 21, 2024
1 parent 6ab7de9 commit 0d28bc3
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions app/repository/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,7 @@ def fetch_data(self, query):
lst_objs = dataframe[col].dropna()
if len(lst_objs) > 0 and isinstance(lst_objs.iloc[0], Decimal):
dataframe[col] = dataframe[col].astype(float)
if len(lst_objs) > 0 and isinstance(lst_objs.iloc[0], bytes):
dataframe[col][0] = dataframe[col][0].decode(chardet.detect(dataframe[col][0])["encoding"])
dataframe[col] = dataframe[col].apply(lambda x: x.decode(chardet.detect(x)["encoding"]) if isinstance(x, bytes) else x)
if dataframe[col].dtype.name == 'datetime64[ns]':
dataframe[col] = dataframe[col].dt.strftime('%Y-%m-%d %H:%M:%S')
return dataframe
Expand Down

0 comments on commit 0d28bc3

Please sign in to comment.