Skip to content

Commit 6a859dd

Browse files
committed
catch other datatype errors for time variable
1 parent c8f4cce commit 6a859dd

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

doubleml/data/panel_data.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,11 @@ def _set_time_var(self):
394394
if hasattr(self, "_data") and self.t_col in self.data.columns:
395395
t_values = self.data.loc[:, self.t_col]
396396
expected_dtypes = (np.integer, np.floating, np.datetime64)
397-
if not any(np.issubdtype(t_values.dtype, dt) for dt in expected_dtypes):
397+
try:
398+
valid_type = any(np.issubdtype(t_values.dtype, dt) for dt in expected_dtypes)
399+
except TypeError:
400+
valid_type = False
401+
if not valid_type:
398402
raise ValueError(f"Invalid data type for time variable: expected one of {expected_dtypes}.")
399403
else:
400404
self._t = t_values

0 commit comments

Comments
 (0)