Skip to content

Commit 71a09eb

Browse files
committed
chucknull -> is_scalar + isna
1 parent 1a9bc97 commit 71a09eb

File tree

5 files changed

+9
-9
lines changed

5 files changed

+9
-9
lines changed

pandas/core/indexes/base.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3728,7 +3728,7 @@ def insert(self, loc, item):
37283728
-------
37293729
new_index : Index
37303730
"""
3731-
if lib.checknull(item):
3731+
if is_scalar(item) and isna(item):
37323732
# GH 18295
37333733
item = self._na_value
37343734

pandas/core/indexes/category.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import numpy as np
2-
from pandas._libs import index as libindex, lib
2+
from pandas._libs import index as libindex
33

44
from pandas import compat
55
from pandas.compat.numpy import function as nv
@@ -12,7 +12,7 @@
1212
is_scalar)
1313
from pandas.core.common import (_asarray_tuplesafe,
1414
_values_from_object)
15-
from pandas.core.dtypes.missing import array_equivalent
15+
from pandas.core.dtypes.missing import array_equivalent, isna
1616
from pandas.core.algorithms import take_1d
1717

1818

@@ -688,7 +688,7 @@ def insert(self, loc, item):
688688
689689
"""
690690
code = self.categories.get_indexer([item])
691-
if (code == -1) and not lib.checknull(item):
691+
if (code == -1) and not (is_scalar(item) and isna(item)):
692692
raise TypeError("cannot insert an item into a CategoricalIndex "
693693
"that is not already an existing category")
694694

pandas/core/indexes/datetimes.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1751,7 +1751,7 @@ def insert(self, loc, item):
17511751
-------
17521752
new_index : Index
17531753
"""
1754-
if lib.checknull(item):
1754+
if is_scalar(item) and isna(item):
17551755
# GH 18295
17561756
item = self._na_value
17571757

pandas/core/indexes/interval.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
Index, _ensure_index,
2323
default_pprint, _index_shared_docs)
2424

25-
from pandas._libs import lib, Timestamp, Timedelta
25+
from pandas._libs import Timestamp, Timedelta
2626
from pandas._libs.interval import (
2727
Interval, IntervalMixin, IntervalTree,
2828
intervals_to_interval_bounds)
@@ -986,7 +986,7 @@ def insert(self, loc, item):
986986
'side as the index')
987987
left_insert = item.left
988988
right_insert = item.right
989-
elif lib.checknull(item):
989+
elif is_scalar(item) and isna(item):
990990
# GH 18295
991991
left_insert = right_insert = item
992992
else:

pandas/core/indexes/timedeltas.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -855,12 +855,12 @@ def insert(self, loc, item):
855855
item = Timedelta(item)
856856
except Exception:
857857
pass
858-
elif lib.checknull(item):
858+
elif is_scalar(item) and isna(item):
859859
# GH 18295
860860
item = self._na_value
861861

862862
freq = None
863-
if isinstance(item, Timedelta) or (item is self._na_value):
863+
if isinstance(item, Timedelta) or (is_scalar(item) and isna(item)):
864864

865865
# check freq can be preserved on edge cases
866866
if self.freq is not None:

0 commit comments

Comments
 (0)