Skip to content

Commit

Permalink
chucknull -> is_scalar + isna
Browse files Browse the repository at this point in the history
  • Loading branch information
jschendel committed Nov 20, 2017
1 parent 1a9bc97 commit 71a09eb
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion pandas/core/indexes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -3728,7 +3728,7 @@ def insert(self, loc, item):
-------
new_index : Index
"""
if lib.checknull(item):
if is_scalar(item) and isna(item):
# GH 18295
item = self._na_value

Expand Down
6 changes: 3 additions & 3 deletions pandas/core/indexes/category.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import numpy as np
from pandas._libs import index as libindex, lib
from pandas._libs import index as libindex

from pandas import compat
from pandas.compat.numpy import function as nv
Expand All @@ -12,7 +12,7 @@
is_scalar)
from pandas.core.common import (_asarray_tuplesafe,
_values_from_object)
from pandas.core.dtypes.missing import array_equivalent
from pandas.core.dtypes.missing import array_equivalent, isna
from pandas.core.algorithms import take_1d


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

Expand Down
2 changes: 1 addition & 1 deletion pandas/core/indexes/datetimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1751,7 +1751,7 @@ def insert(self, loc, item):
-------
new_index : Index
"""
if lib.checknull(item):
if is_scalar(item) and isna(item):
# GH 18295
item = self._na_value

Expand Down
4 changes: 2 additions & 2 deletions pandas/core/indexes/interval.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
Index, _ensure_index,
default_pprint, _index_shared_docs)

from pandas._libs import lib, Timestamp, Timedelta
from pandas._libs import Timestamp, Timedelta
from pandas._libs.interval import (
Interval, IntervalMixin, IntervalTree,
intervals_to_interval_bounds)
Expand Down Expand Up @@ -986,7 +986,7 @@ def insert(self, loc, item):
'side as the index')
left_insert = item.left
right_insert = item.right
elif lib.checknull(item):
elif is_scalar(item) and isna(item):
# GH 18295
left_insert = right_insert = item
else:
Expand Down
4 changes: 2 additions & 2 deletions pandas/core/indexes/timedeltas.py
Original file line number Diff line number Diff line change
Expand Up @@ -855,12 +855,12 @@ def insert(self, loc, item):
item = Timedelta(item)
except Exception:
pass
elif lib.checknull(item):
elif is_scalar(item) and isna(item):
# GH 18295
item = self._na_value

freq = None
if isinstance(item, Timedelta) or (item is self._na_value):
if isinstance(item, Timedelta) or (is_scalar(item) and isna(item)):

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

0 comments on commit 71a09eb

Please sign in to comment.