Skip to content

Commit 9886c8d

Browse files
committed
parcoords.py: Fix get_limits compatibility with pandas 3.0 string dtype
Pandas 3.0 now infers string columns as the dedicated string dtype instead of object dtype by default. This caused get_limits() to fail recognizing categorical columns, returning individual values instead of sets of unique values. The fix adds a check for string dtype using pd.api.types.is_string_dtype() alongside the existing object dtype check, ensuring categorical/string columns are properly handled regardless of pandas version. Fixes test failures in test_get_limits and test_plot when using pandas 3.0.0rc1 (--pre flag).
1 parent ac79c1a commit 9886c8d

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

ema_workbench/analysis/parcoords.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def setup_parallel_plot(labels, minima, maxima, formatter=None, fs=14, rot=90):
101101

102102

103103
def get_limits(data):
104-
"""Helper function to get limits of a FataFrame that can serve as input to ParallelAxis.
104+
"""Helper function to get limits of a DataFrame that can serve as input to ParallelAxis.
105105
106106
Parameters
107107
----------
@@ -110,11 +110,9 @@ def get_limits(data):
110110
Returns
111111
-------
112112
DataFrame
113-
114113
"""
115-
116114
def limits(x):
117-
if x.dtype == "object":
115+
if x.dtype == "object" or pd.api.types.is_string_dtype(x.dtype):
118116
return pd.Series([set(x), set(x)])
119117
else:
120118
return pd.Series([x.min(), x.max()])

0 commit comments

Comments
 (0)