Sep-01-2023, 06:29 AM
Hi,
I have this piece of code that used to work. I have upgraded Numpy and Pandas and now they don't seem to work.
I have this piece of code that used to work. I have upgraded Numpy and Pandas and now they don't seem to work.
def astype(self, dtype, copy: bool = True): # We handle # --> timedelta64[ns] # --> timedelta64 # DatetimeLikeArrayMixin super call handles other cases dtype = pandas_dtype(dtype) if lib.is_np_dtype(dtype, "m"): if dtype == self.dtype: if copy: return self.copy() return self if is_supported_unit(get_unit_from_dtype(dtype)): # unit conversion e.g. timedelta64[s] res_values = astype_overflowsafe(self._ndarray, dtype, copy=False) return type(self)._simple_new( res_values, dtype=res_values.dtype, freq=self.freq ) else: raise ValueError( f"Cannot convert from {self.dtype} to {dtype}. " "Supported resolutions are 's', 'ms', 'us', 'ns'" ) return dtl.DatetimeLikeArrayMixin.astype(self, dtype, copy=copy)I'm getting this error:
Output:raise ValueError(
ValueError: Cannot convert from timedelta64[ns] to timedelta64[h]. Supported resolutions are 's', 'ms', 'us', 'ns'