77
88from deepnote_toolkit .ocelots .constants import DEEPNOTE_INDEX_COLUMN
99from deepnote_toolkit .ocelots .pandas .utils import (
10+ is_numeric_or_temporal ,
1011 is_type_datetime_or_timedelta ,
11- is_type_numeric ,
1212 safe_convert_to_string ,
1313)
1414from deepnote_toolkit .ocelots .types import ColumnsStatsRecord , ColumnStats
@@ -58,8 +58,6 @@ def _get_histogram(pd_series):
5858 try :
5959 if is_type_datetime_or_timedelta (pd_series ):
6060 np_array = np .array (pd_series .dropna ().astype (int ))
61- elif np .issubdtype (pd_series .dtype , np .complexfloating ):
62- return None
6361 else :
6462 # let's drop infinite values because they break histograms
6563 np_array = np .array (pd_series .replace ([np .inf , - np .inf ], np .nan ).dropna ())
@@ -90,14 +88,7 @@ def _calculate_min_max(column):
9088 """
9189 Calculate min and max values for a given column.
9290 """
93- if not is_type_numeric (column .dtype ):
94- return None , None
95-
96- # Complex numbers cannot be compared for min/max
97- # Check for datetime/timedelta types before because np.issubdtype doesn't work reliably on them
98- if not is_type_datetime_or_timedelta (column ) and np .issubdtype (
99- column .dtype , np .complexfloating
100- ):
91+ if not is_numeric_or_temporal (column .dtype ):
10192 return None , None
10293
10394 try :
@@ -164,7 +155,7 @@ def analyze_columns(
164155 unique_count = _count_unique (column ), nan_count = column .isnull ().sum ().item ()
165156 )
166157
167- if is_type_numeric (column .dtype ):
158+ if is_numeric_or_temporal (column .dtype ):
168159 min_value , max_value = _calculate_min_max (column )
169160 columns [i ].stats .min = min_value
170161 columns [i ].stats .max = max_value
@@ -184,7 +175,7 @@ def analyze_columns(
184175 for i in range (max_columns_to_analyze , len (df .columns )):
185176 # Ignore columns that are not numeric
186177 column = df .iloc [:, i ]
187- if not is_type_numeric (column .dtype ):
178+ if not is_numeric_or_temporal (column .dtype ):
188179 continue
189180
190181 column_name = columns [i ].name
0 commit comments