Skip to content

Commit c3358f2

Browse files
committed
when passing None and other NA values to NumericIndex the value should become nan
1 parent 34b0eb1 commit c3358f2

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

pandas/core/indexes/numeric.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
is_bool,
1010
is_bool_dtype,
1111
is_scalar)
12+
from pandas.core.dtypes.missing import isna
1213

1314
from pandas import compat
1415
from pandas.core import algorithms
@@ -114,6 +115,12 @@ def is_all_dates(self):
114115
"""
115116
return False
116117

118+
def insert(self, loc, item):
119+
# treat NA values as nans:
120+
if is_scalar(item) and isna(item):
121+
item = np.nan
122+
return super(NumericIndex, self).insert(loc, item)
123+
117124

118125
_num_index_shared_docs['class_descr'] = """
119126
Immutable ndarray implementing an ordered, sliceable set. The basic object

0 commit comments

Comments
 (0)