Skip to content

Commit

Permalink
Improve the checking of dtypes
Browse files Browse the repository at this point in the history
  • Loading branch information
seisman committed Dec 12, 2024
1 parent c188779 commit 18057c1
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pygmt/clib/conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -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").
Expand Down

0 comments on commit 18057c1

Please sign in to comment.