Is your feature request related to a problem?
I found that:
pd.NA ** 0 # The result is 1
pd.NA * 0 # The result is pd.NA
Describe the solution you'd like
Personally, I think the pow
and mul
method shoulds be consistent. The results should be both NA or both numbers.
Solution 1:
pd.NA ** 0 # The result is pd.NA
pd.NA * 0 # The result is pd.NA
Solution 2:
pd.NA ** 0 # The result is 1
pd.NA * 0 # The result is 0
PS: I assume the pd.NA is not infinite.
Comment From: TomAugspurger
xref https://github.com/pandas-dev/pandas/issues/29997.
PS: I assume the pd.NA is not infinite.
I think that's the issue. Similar to how np.inf * 0
isn't defined (returns np.nan
) we don't know what the output of pd.NA * 0
should be. That differs from pd.NA ** 0
which is 1 by definition.
Comment From: tushushu
That makes sense. But NA**0 == 1 is also confusing, shouldn't it be 1 or 1.0? How do we know the NA is representing a integer?
Comment From: TomAugspurger
I think that gets into a larger discussion around "typed NA" (or NA[T]
). https://github.com/pandas-dev/pandas/issues/28095
Comment From: tushushu
Thanks @TomAugspurger for sharing these discussions, it's really insightful.