-
-
Notifications
You must be signed in to change notification settings - Fork 18.7k
Closed
Labels
BugExtensionArrayExtending pandas with custom dtypes or arrays.Extending pandas with custom dtypes or arrays.NA - MaskedArraysRelated to pd.NA and nullable extension arraysRelated to pd.NA and nullable extension arraysNumeric OperationsArithmetic, Comparison, and Logical operationsArithmetic, Comparison, and Logical operations
Description
In [5]: pd.Series([1], dtype='Int64') / pd.Series([0], dtype='Int64')
Out[5]:
0 NaN
dtype: float64
Where as
In [6]: pd.Series([1], dtype='int64') / pd.Series([0], dtype='int64')
Out[6]:
0 inf
dtype: float64
It's because of this line:
pandas/pandas/core/arrays/integer.py
Line 545 in 0480f4c
mask |= (result == np.inf) | (result == -np.inf) |
Is it intentional for the new extension integer type to have different behavior here?
Metadata
Metadata
Assignees
Labels
BugExtensionArrayExtending pandas with custom dtypes or arrays.Extending pandas with custom dtypes or arrays.NA - MaskedArraysRelated to pd.NA and nullable extension arraysRelated to pd.NA and nullable extension arraysNumeric OperationsArithmetic, Comparison, and Logical operationsArithmetic, Comparison, and Logical operations
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
WillAyd commentedon Sep 20, 2018
These should align though I think the extension type actually handles this more correctly
jorisvandenbossche commentedon Sep 21, 2018
I am not sure we should change the behaviour of Series with default numpy types, as we then would deviate from numpy behaviour.
Of course for the extension Int type, we have better handling of NA compared to numpy int, so which could be a reason to actually use that here. But, since division will always result in a floating dtype (and never integer), that's not a direct benefit in this case.
We have a
pd.options.mode.use_inf_as_na
so people can make this in practice to behave as NA, but that is False by default.jbrockmendel commentedon Jan 2, 2022
closed by #30183