diff --git a/xarray/core/duck_array_ops.py b/xarray/core/duck_array_ops.py index 078aab0ed63..51b6ff5f59b 100644 --- a/xarray/core/duck_array_ops.py +++ b/xarray/core/duck_array_ops.py @@ -184,6 +184,9 @@ def cumulative_trapezoid(y, x, axis): def astype(data, dtype, **kwargs): if hasattr(data, "__array_namespace__"): xp = get_array_namespace(data) + if xp == np: + # numpy currently doesn't have a astype: + return data.astype(dtype, **kwargs) return xp.astype(data, dtype, **kwargs) return data.astype(dtype, **kwargs)