You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Both pandas and xarray now have a to_numpy method on their data objects. We only use to_numpy once in cbook._reshape_2D, and instead usually check .values. We probably should be using to_numpy more if that is indeed the new idiom for converting?
Ping @shoyer for xarray and @TomAugspurger for pandas, though please feel free to redirect as appropriate, you are being picked upon because you've interacted with us before 😉.
One thing I note for to_numpy and dates is that it does not seem to convert to numpy datetime64 or timedelta64 for either package - it'd be nice if they did!
In general, I recommend using to_numpy() or np.asarray rather than .values. Then you know for certain that you have an ndarray.
One thing I note for to_numpy and dates is that it does not seem to convert to numpy datetime64 or timedelta64 for either package - it'd be nice if they did!
Just confirming, you mean dates (and not datetimes)? In pandas, those will be stored as object dtype, and I don't think to_numpy() is the right spot to do type inference or conversion.
This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!
Activity
TomAugspurger commentedon Sep 10, 2021
In general, I recommend using
to_numpy()ornp.asarrayrather than.values. Then you know for certain that you have an ndarray.Just confirming, you mean dates (and not datetimes)? In pandas, those will be stored as object dtype, and I don't think
to_numpy()is the right spot to do type inference or conversion.jklymak commentedon Sep 10, 2021
Ok, we definitely use np.asarray however I'll admit my ignorance as to the difference with to_numpy.
TomAugspurger commentedon Sep 11, 2021
IIRC there were some differences (maybe datetimes with timezones silently cast to UTC in asarray?) but that was deprecated and fixed.
So the main reason to use
to_numpy()now comes from control overna_value, and perhapscopy.github-actions commentedon Nov 3, 2025
This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!
timhoffm commentedon Nov 3, 2025
On a higher level, this is tracked in #22645. On the technical side, we should orient towards the array API standard #22645 (comment).