Pandas version checks
-
[x] I have checked that this issue has not already been reported.
-
[x] I have confirmed this bug exists on the latest version of pandas.
-
[x] I have confirmed this bug exists on the main branch of pandas.
Reproducible Example
import pandas as pd, numpy as np
arr = np.array(["a"], dtype=np.dtype("O", metadata={"foo":"bar"}))
assert pd.Series(arr).to_numpy().dtype.metadata is not None
Issue Description
The above does not have an assertion error under pandas<3
(i.e., 2.3.1
) but does as of the displayed versions. I apologize if I'm not supposed to report this - I see the "I have confirmed this bug exists on the latest version of pandas." box but of course, it doesn't appear to happen on 2.3.1
. This came up in https://github.com/pydata/xarray/pull/10564
It occurs to me now that 3.0.0 may not be what is on main
but that is the reported version so I'm not sure if this is a 3.0.0 problem or a main
problem but here is how I work around it:
https://github.com/pydata/xarray/pull/10564/files#diff-43c76e9be8425b5b6897dcecab4b240c32580447455c0c8c0b9b7fd84ce8a15dR221-R228
See https://github.com/pydata/xarray/issues/10553 for the origin of this issue
Expected Behavior
metadata
is maintained