pandas: Maybe buggy nullable integer floor division by 0

From @jschendel in https://github.com/pandas-dev/pandas/pull/30183#issuecomment-564255221

In [6]: a = pd.array([0, 1, -1, None], dtype="Int64")

In [7]: a // 0
Out[7]: 
<IntegerArray>
[0, 0, 0, NaN]
Length: 4, dtype: Int64

In [8]: a // -0
Out[8]: 
<IntegerArray>
[0, 0, 0, NaN]
Length: 4, dtype: Int64

In [9]: a // 0.0
Out[9]: array([nan, nan, nan, nan])

In [10]: a // -0.0
Out[10]: array([nan, nan, nan, nan])

Those should probably all be NA, to match the ndarray behavior.

About this issue

  • Original URL
  • State: open
  • Created 5 years ago
  • Comments: 23 (21 by maintainers)

Most upvoted comments

Suppose we agree that IntegerArray should behave like Series.

So what is the rationale of the current Series behaviour for floor division by 0? When returning a float result, why not follow numpy’s behaviour for floats of returning all NaN ?