Skip to content

Commit

Permalink
fix potential errors for older versions of pandas package
Browse files Browse the repository at this point in the history
  • Loading branch information
wenh06 committed Jul 18, 2024
1 parent 81ae319 commit 9dc2530
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion torch_ecg/utils/utils_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,10 @@ def stratified_train_test_split(
)
stratified_cols = [col for col in stratified_cols if col not in invalid_cols]
# map to str to avoid incorrect comparison of nan values
df_inspection = df[stratified_cols].copy().map(str)
try:
df_inspection = df[stratified_cols].copy().map(str)
except AttributeError:
df_inspection = df[stratified_cols].copy().applymap(str)
for item in stratified_cols:
all_entities = df_inspection[item].unique().tolist()
entities_dict = {e: str(i) for i, e in enumerate(all_entities)}
Expand Down

0 comments on commit 9dc2530

Please sign in to comment.