Skip to content

Commit a951f27

Browse files
committed
chucknull -> is_scalar + isna
1 parent 12bcfed commit a951f27

File tree

5 files changed

+9
-9
lines changed

5 files changed

+9
-9
lines changed

pandas/core/indexes/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3734,7 +3734,7 @@ def insert(self, loc, item):
37343734
-------
37353735
new_index : Index
37363736
"""
3737-
if lib.checknull(item):
3737+
if is_scalar(item) and isna(item):
37383738
# GH 18295
37393739
item = self._na_value
37403740

pandas/core/indexes/category.py

Lines changed: 3 additions & 3 deletions
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

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

pandas/core/indexes/datetimes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1757,7 +1757,7 @@ def insert(self, loc, item):
17571757
-------
17581758
new_index : Index
17591759
"""
1760-
if lib.checknull(item):
1760+
if is_scalar(item) and isna(item):
17611761
# GH 18295
17621762
item = self._na_value
17631763

pandas/core/indexes/interval.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
Index, _ensure_index,
2424
default_pprint, _index_shared_docs)
2525

26-
from pandas._libs import lib, Timestamp, Timedelta
26+
from pandas._libs import Timestamp, Timedelta
2727
from pandas._libs.interval import (
2828
Interval, IntervalMixin, IntervalTree,
2929
intervals_to_interval_bounds)
@@ -1007,7 +1007,7 @@ def insert(self, loc, item):
10071007
'side as the index')
10081008
left_insert = item.left
10091009
right_insert = item.right
1010-
elif lib.checknull(item):
1010+
elif is_scalar(item) and isna(item):
10111011
# GH 18295
10121012
left_insert = right_insert = item
10131013
else:

pandas/core/indexes/timedeltas.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -858,12 +858,12 @@ def insert(self, loc, item):
858858
item = Timedelta(item)
859859
except Exception:
860860
pass
861-
elif lib.checknull(item):
861+
elif is_scalar(item) and isna(item):
862862
# GH 18295
863863
item = self._na_value
864864

865865
freq = None
866-
if isinstance(item, Timedelta) or (item is self._na_value):
866+
if isinstance(item, Timedelta) or (is_scalar(item) and isna(item)):
867867

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

0 commit comments

Comments
 (0)