Open scanzy opened 2 weeks ago
The difference is due to the underlying data type:
s = pd.Series([float("nan"), 0.0], dtype="pint[MW]")
s.values.data
<FloatingArray>
[<NA>, 0.0]
Length: 2, dtype: Float64
s = pd.Series([float("nan")], dtype="pint[MW]")
s.values.data
<NumpyExtensionArray>
[nan]
Length: 1, dtype: float64
I think pint-pandas should by:
Hello, I am facing this issue while building a
pd.Series
with pint dtype.float("nan")
is alone, it remainsfloat("nan")
.float("nan")
is with other values, it is converted intopd.NA
.This is not evident printing the series (the formatting shows always
nan
), butvalues
ortolist()
reveal the difference.I supposed that
float("nan")
was the default value meaning "not set magnitude". The fact that nan is converted topd.NA
based on other values in the series looks bit tricky to me: is it intended?I am looking a way to keep not-set values consistent (either all
float("nan")
, or allpd.NA
), but:pd.NA
tofloat("nan")
has no effect.float("nan")
topd.NA
I getValueError
.