Float32Dtype and Float64Dtype for nullable floats (which gives a way to distinguish a NaN that was produced by invalid computation from a True missing value)
which are all based on pandas.NA. Because missing values are becoming more and more important to handle, we see other projects supporting this feature as well, for example
What does to_numpy or .values do? We don't directly do anything with pandas data types except immediately turn them into numpy arrays.
If numpy starts supporting other invalid flags we can discuss what to do (probably just add a bunch of redundant checks) but from Matlotlibs point of view I'm not sure there is an action here?
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!
We don't include pandas as a dependency (except for tests).
I'm not sure what we are supposed to do here - if to_numpy just returns an object array with pandas objects in it, then we can't deal with it. I think this is a pandas (and perhaps numpy issue). Numpy has formally handled identifying missing data using masked arrays. I don't think masked arrays have proven very popular, and, practically, most of the world is fine with NaN as a bad data sentinel. Given this issue is 4 years old, I'm guessing pd.NA has suffered a similar lack of use.
In order to carry pd.NA (and thus be affected by it) the pandas data types must be specific nullable pandas datatype. I've performed checks like
In [5]: pd.Series([1, pd.NA, 3], dtype="Float64").to_numpy().dtypeOut[5]: dtype('float64')
pandas nullable dtype
to_numpy().dtype
Int64
float64
Float32
float32
Float64
float64
boolean
object
So the numeric types are converted to floats and pd.NA is represented as NaN. The boolean type is converted to object. This behavior with default to_numpy() brings compatibility with matplotlib as good as we can get. For visualization it is typically irrelevant that Int64 is converted to float. Bool values should be quite rare for visualization and there is no native numpy type that can reasonably represent NA (converting bool to float would be a bit stretched to far). So for now, there is nothing to do.
With "future.distinguish_nan_and_na" enabled, ser.to_numpy() (and frame.values and np.asarray(obj)) will convert to object dtype if NA entries are present, where before they would coerce to NaN. To retain a float numpy dtype, explicitly pass na_value=np.nan to Series.to_numpy().
So we may consider switching to to_numpy(na_value=np.nan). Otherwise, we loose support for Int64, Float32 and Float64.
Note: We don't need to import pandas to support this. It is sufficient to inspect whether the type is a pandas type or try...except with the na_value kwarg.
Activity
jklymak commented on Jan 6, 2022
What does to_numpy or .values do? We don't directly do anything with pandas data types except immediately turn them into numpy arrays.
If numpy starts supporting other invalid flags we can discuss what to do (probably just add a bunch of redundant checks) but from Matlotlibs point of view I'm not sure there is an action here?
oscargus commented on Apr 10, 2022
It seems like to_numpy is not converting the NA values. Conditionally if dtype=object.
In [5]: df Out[5]: col1 col2 0 1 3 1 2 <NA> In [6]: df.to_numpy() Out[6]: array([[1, 3], [2, <NA>]], dtype=object)oscargus commented on Apr 10, 2022
Pandas has a keyword argument na_value that can be use to replace the NA values during conversion. https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.to_numpy.html
However, xarray does not.
github-actions commented on Dec 1, 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 commented on Jan 2, 2026
We should handle pd.NA (or explicitly decide that we can't do this).
At least for numeric data, I suspect that we could convert pd.NA to NaN.
jklymak commented on Jan 2, 2026
We don't include pandas as a dependency (except for tests).
I'm not sure what we are supposed to do here - if to_numpy just returns an object array with pandas objects in it, then we can't deal with it. I think this is a pandas (and perhaps numpy issue). Numpy has formally handled identifying missing data using masked arrays. I don't think masked arrays have proven very popular, and, practically, most of the world is fine with NaN as a bad data sentinel. Given this issue is 4 years old, I'm guessing pd.NA has suffered a similar lack of use.
timhoffm commented on Jan 2, 2026
What currently works and what doesn't
In order to carry pd.NA (and thus be affected by it) the pandas data types must be specific nullable pandas datatype. I've performed checks like
So the numeric types are converted to floats and pd.NA is represented as NaN. The boolean type is converted to object. This behavior with default to_numpy() brings compatibility with matplotlib as good as we can get. For visualization it is typically irrelevant that Int64 is converted to float. Bool values should be quite rare for visualization and there is no native numpy type that can reasonably represent NA (converting bool to float would be a bit stretched to far). So for now, there is nothing to do.
What changes with pandas 3
However, it seems that pandas 3 changes the above. https://pandas.pydata.org/docs/dev/whatsnew/v3.0.0.html#changed-treatment-of-nan-values-in-pyarrow-and-numpy-nullable-floating-dtypes
So we may consider switching to to_numpy(na_value=np.nan). Otherwise, we loose support for Int64, Float32 and Float64.
Note: We don't need to import pandas to support this. It is sufficient to inspect whether the type is a pandas type or try...except with the na_value kwarg.