From 18057c1cbcbb32a17a081910e8bd6545e743ee6e Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Thu, 12 Dec 2024 17:49:24 +0800 Subject: [PATCH] Improve the checking of dtypes --- pygmt/clib/conversion.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pygmt/clib/conversion.py b/pygmt/clib/conversion.py index b86ce7016b7..e3531d04709 100644 --- a/pygmt/clib/conversion.py +++ b/pygmt/clib/conversion.py @@ -194,10 +194,10 @@ def _to_numpy(data: Any) -> np.ndarray: data = data.to_numpy(na_value=np.nan) # Deal with timezone-aware datetime dtypes. - if getattr(dtype, "tz", None): # pandas.DatetimeTZDtype + if isinstance(dtype, pd.DatetimeTZDtype): # pandas.DatetimeTZDtype numpy_dtype = getattr(dtype, "base", None) - elif getattr(dtype, "pyarrow_dtype", None) and hasattr(dtype.pyarrow_dtype, "tz"): - # pd.ArrayDtype[pa.Timestamp] + elif isinstance(dtype, pd.ArrowDtype) and hasattr(dtype.pyarrow_dtype, "tz"): + # pd.ArrowDtype[pa.Timestamp] numpy_dtype = getattr(dtype, "numpy_dtype", None) if Version(pd.__version__) < Version("2.1"): # In pandas 2.0, dtype.numpy_type is dtype("O").