File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -2277,6 +2277,21 @@ def name(self) -> str: # type: ignore[override]
2277
2277
@cache_readonly
2278
2278
def numpy_dtype (self ) -> np .dtype :
2279
2279
"""Return an instance of the related numpy dtype"""
2280
+ if pa .types .is_timestamp (self .pyarrow_dtype ):
2281
+ # pa.timestamp(unit).to_pandas_dtype() returns ns units
2282
+ # regardless of the pyarrow timestamp units.
2283
+ # This can be removed if/when pyarrow addresses it:
2284
+ # https://github.com/apache/arrow/issues/34462
2285
+ if self .pyarrow_dtype .tz is not None :
2286
+ np .dtype (self .pyarrow_dtype .to_pandas_dtype ())
2287
+ else :
2288
+ return np .dtype (f"datetime64[{ self .pyarrow_dtype .unit } ]" )
2289
+ if pa .types .is_duration (self .pyarrow_dtype ):
2290
+ # pa.duration(unit).to_pandas_dtype() returns ns units
2291
+ # regardless of the pyarrow duration units
2292
+ # This can be removed if/when pyarrow addresses it:
2293
+ # https://github.com/apache/arrow/issues/34462
2294
+ return np .dtype (f"timedelta64[{ self .pyarrow_dtype .unit } ]" )
2280
2295
if pa .types .is_string (self .pyarrow_dtype ) or pa .types .is_large_string (
2281
2296
self .pyarrow_dtype
2282
2297
):
You can’t perform that action at this time.
0 commit comments