@@ -2274,32 +2274,30 @@ def name(self) -> str: # type: ignore[override]
22742274
22752275 @cache_readonly
22762276 def numpy_dtype (self ) -> np .dtype :
2277- """Return an instance of the related numpy dtype."""
2278- if pa .types .is_timestamp (self .pyarrow_dtype ):
2279- if self .pyarrow_dtype .tz is not None :
2277+ """Return an instance of the related numpy dtype."""
2278+ if pa .types .is_timestamp (self .pyarrow_dtype ):
2279+ if self .pyarrow_dtype .tz is not None :
2280+ return np .dtype (f"datetime64[{ self .pyarrow_dtype .unit } ]" )
22802281 return np .dtype (f"datetime64[{ self .pyarrow_dtype .unit } ]" )
2281- return np .dtype (f"datetime64[{ self .pyarrow_dtype .unit } ]" )
2282- if pa .types .is_duration (self .pyarrow_dtype ):
2283- return np .dtype (f"timedelta64[{ self .pyarrow_dtype .unit } ]" )
2284- if pa .types .is_string (self .pyarrow_dtype ) or pa .types .is_large_string (
2285- self .pyarrow_dtype
2286- ):
2287- return np .dtype (str )
2288- try :
2289- np_dtype = self .pyarrow_dtype .to_pandas_dtype ()
2290-
2291- if isinstance (np_dtype , object ):
2292- if hasattr (np_dtype , "categories" ) and isinstance (np_dtype .categories , pd .IntervalIndex ):
2293- return np .dtype (object )
2294-
2295- if isinstance (np_dtype , DatetimeTZDtype ):
2296- return np .dtype (f"datetime64[{ np_dtype .unit } ]" )
2297-
2298- return np .dtype (np_dtype )
2299- except (NotImplementedError , TypeError ):
2300- return np .dtype (object )
2301-
2302-
2282+ if pa .types .is_duration (self .pyarrow_dtype ):
2283+ return np .dtype (f"timedelta64[{ self .pyarrow_dtype .unit } ]" )
2284+ if pa .types .is_string (self .pyarrow_dtype ) or pa .types .is_large_string (
2285+ self .pyarrow_dtype
2286+ ):
2287+ return np .dtype (str )
2288+ try :
2289+ np_dtype = self .pyarrow_dtype .to_pandas_dtype ()
2290+
2291+ if isinstance (np_dtype , object ):
2292+ if hasattr (np_dtype , "categories" ) and isinstance (np_dtype .categories , pd .IntervalIndex ):
2293+ return np .dtype (object )
2294+
2295+ if isinstance (np_dtype , DatetimeTZDtype ):
2296+ return np .dtype (f"datetime64[{ np_dtype .unit } ]" )
2297+
2298+ return np .dtype (np_dtype )
2299+ except (NotImplementedError , TypeError ):
2300+ return np .dtype (object )
23032301
23042302 @cache_readonly
23052303 def kind (self ) -> str :
0 commit comments