Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Revert skipna=True where it was added
  • Loading branch information
h-vetinari committed Jan 3, 2019
commit fd8c0101f5ec07a302326f7c9bc2b29ddf5644cf
2 changes: 1 addition & 1 deletion pandas/core/algorithms.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def _ensure_arraylike(values):
ensure that we are arraylike if not already
"""
if not is_array_like(values):
inferred = lib.infer_dtype(values, skipna=True)
inferred = lib.infer_dtype(values, skipna=False)
if inferred in ['mixed', 'string', 'unicode']:
if isinstance(values, tuple):
values = list(values)
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/arrays/array_.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ def array(data, # type: Sequence[object]
return cls._from_sequence(data, dtype=dtype, copy=copy)

if dtype is None:
inferred_dtype = lib.infer_dtype(data, skipna=True)
inferred_dtype = lib.infer_dtype(data, skipna=False)
if inferred_dtype == 'period':
try:
return period_array(data, copy=copy)
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/arrays/datetimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1678,7 +1678,7 @@ def sequence_to_dt64ns(data, dtype=None, copy=False,
# TODO: We do not have tests specific to string-dtypes,
# also complex or categorical or other extension
copy = False
if lib.infer_dtype(data, skipna=True) == 'integer':
if lib.infer_dtype(data, skipna=False) == 'integer':
data = data.astype(np.int64)
else:
# data comes back here as either i8 to denote UTC timestamps
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/arrays/timedeltas.py
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ def __floordiv__(self, other):
elif is_object_dtype(other):
result = [self[n] // other[n] for n in range(len(self))]
result = np.array(result)
if lib.infer_dtype(result, skipna=True) == 'timedelta':
if lib.infer_dtype(result, skipna=False) == 'timedelta':
result, _ = sequence_to_td64ns(result)
return type(self)(result)
return result
Expand Down
4 changes: 2 additions & 2 deletions pandas/core/dtypes/cast.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def trans(x):
if isinstance(dtype, string_types):
if dtype == 'infer':
inferred_type = lib.infer_dtype(ensure_object(result.ravel()),
skipna=True)
skipna=False)
if inferred_type == 'boolean':
dtype = 'bool'
elif inferred_type == 'integer':
Expand Down Expand Up @@ -461,7 +461,7 @@ def infer_dtype_from_array(arr, pandas_dtype=False):
return arr.dtype, np.asarray(arr)

# don't force numpy coerce with nan's
inferred = lib.infer_dtype(arr, skipna=True)
inferred = lib.infer_dtype(arr, skipna=False)
if inferred in ['string', 'bytes', 'unicode',
'mixed', 'mixed-integer']:
return (np.object_, arr)
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/dtypes/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,7 @@ def is_datetime_arraylike(arr):
return True
elif isinstance(arr, (np.ndarray, ABCSeries)):
return (is_object_dtype(arr.dtype)
and lib.infer_dtype(arr, skipna=True) == 'datetime')
and lib.infer_dtype(arr, skipna=False) == 'datetime')
return getattr(arr, 'inferred_type', None) == 'datetime'


Expand Down
2 changes: 1 addition & 1 deletion pandas/core/dtypes/missing.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ def _infer_fill_value(val):
if is_datetimelike(val):
return np.array('NaT', dtype=val.dtype)
elif is_object_dtype(val.dtype):
dtype = lib.infer_dtype(ensure_object(val), skipna=True)
dtype = lib.infer_dtype(ensure_object(val), skipna=False)
if dtype in ['datetime', 'datetime64']:
return np.array('NaT', dtype=_NS_DTYPE)
elif dtype in ['timedelta', 'timedelta64']:
Expand Down
6 changes: 3 additions & 3 deletions pandas/core/indexes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ def __new__(cls, data=None, dtype=None, copy=False, name=None,
# should not be coerced
# GH 11836
if is_integer_dtype(dtype):
inferred = lib.infer_dtype(data, skipna=True)
inferred = lib.infer_dtype(data, skipna=False)
if inferred == 'integer':
data = maybe_cast_to_integer_array(data, dtype,
copy=copy)
Expand Down Expand Up @@ -376,7 +376,7 @@ def __new__(cls, data=None, dtype=None, copy=False, name=None,
else:
data = data.astype(dtype)
elif is_float_dtype(dtype):
inferred = lib.infer_dtype(data, skipna=True)
inferred = lib.infer_dtype(data, skipna=False)
if inferred == 'string':
pass
else:
Expand Down Expand Up @@ -1718,7 +1718,7 @@ def inferred_type(self):
"""
Return a string of the type inferred from the values.
"""
return lib.infer_dtype(self, skipna=True)
return lib.infer_dtype(self, skipna=False)

@cache_readonly
def is_all_dates(self):
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/indexes/multi.py
Original file line number Diff line number Diff line change
Expand Up @@ -2319,7 +2319,7 @@ def _partial_tup_index(self, tup, side='left'):

if lab not in lev:
if not lev.is_type_compatible(lib.infer_dtype([lab],
skipna=True)):
skipna=False)):
raise TypeError('Level type mismatch: %s' % lab)

# short circuit
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/internals/construction.py
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,7 @@ def sanitize_array(data, index, dtype=None, copy=False,
subarr = np.array(data, dtype=object, copy=copy)

if is_object_dtype(subarr.dtype) and dtype != 'object':
inferred = lib.infer_dtype(subarr, skipna=True)
inferred = lib.infer_dtype(subarr, skipna=False)
if inferred == 'period':
try:
subarr = period_array(subarr)
Expand Down
8 changes: 4 additions & 4 deletions pandas/core/reshape/merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -947,8 +947,8 @@ def _maybe_coerce_merge_keys(self):
continue

# let's infer and see if we are ok
elif (lib.infer_dtype(lk, skipna=True)
== lib.infer_dtype(rk, skipna=True)):
elif (lib.infer_dtype(lk, skipna=False)
== lib.infer_dtype(rk, skipna=False)):
continue

# Check if we are trying to merge on obviously
Expand All @@ -962,8 +962,8 @@ def _maybe_coerce_merge_keys(self):
# object values are allowed to be merged
elif ((lk_is_object and is_numeric_dtype(rk)) or
(is_numeric_dtype(lk) and rk_is_object)):
inferred_left = lib.infer_dtype(lk, skipna=True)
inferred_right = lib.infer_dtype(rk, skipna=True)
inferred_left = lib.infer_dtype(lk, skipna=False)
inferred_right = lib.infer_dtype(rk, skipna=False)
bool_types = ['integer', 'mixed-integer', 'boolean', 'empty']
string_types = ['string', 'unicode', 'mixed', 'bytes', 'empty']

Expand Down
2 changes: 1 addition & 1 deletion pandas/core/reshape/tile.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ def _convert_bin_to_numeric_type(bins, dtype):
------
ValueError if bins are not of a compat dtype to dtype
"""
bins_dtype = infer_dtype(bins, skipna=True)
bins_dtype = infer_dtype(bins, skipna=False)
if is_timedelta64_dtype(dtype):
if bins_dtype in ['timedelta', 'timedelta64']:
bins = to_timedelta(bins).view(np.int64)
Expand Down
4 changes: 2 additions & 2 deletions pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -875,7 +875,7 @@ def _get_with(self, key):
if isinstance(key, Index):
key_type = key.inferred_type
else:
key_type = lib.infer_dtype(key, skipna=True)
key_type = lib.infer_dtype(key, skipna=False)

if key_type == 'integer':
if self.index.is_integer() or self.index.is_floating():
Expand Down Expand Up @@ -1012,7 +1012,7 @@ def _set_with(self, key, value):
if isinstance(key, Index):
key_type = key.inferred_type
else:
key_type = lib.infer_dtype(key, skipna=True)
key_type = lib.infer_dtype(key, skipna=False)

if key_type == 'integer':
if self.index.inferred_type == 'integer':
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/sorting.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ def sort_mixed(values):
return np.concatenate([nums, np.asarray(strs, dtype=object)])

sorter = None
if PY3 and lib.infer_dtype(values, skipna=True) == 'mixed-integer':
if PY3 and lib.infer_dtype(values, skipna=False) == 'mixed-integer':
# unorderable in py3 if mixed str/int
ordered = sort_mixed(values)
else:
Expand Down
2 changes: 1 addition & 1 deletion pandas/io/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1300,7 +1300,7 @@ def _validate_usecols_arg(usecols):
elif not is_list_like(usecols):
raise ValueError(msg)
else:
usecols_dtype = lib.infer_dtype(usecols, skipna=True)
usecols_dtype = lib.infer_dtype(usecols, skipna=False)
if usecols_dtype not in ('empty', 'integer',
'string', 'unicode'):
raise ValueError(msg)
Expand Down
12 changes: 6 additions & 6 deletions pandas/io/pytables.py
Original file line number Diff line number Diff line change
Expand Up @@ -1952,7 +1952,7 @@ def set_atom(self, block, block_items, existing_col, min_itemsize,
return self.set_atom_complex(block)

dtype = block.dtype.name
inferred_type = lib.infer_dtype(block.values, skipna=True)
inferred_type = lib.infer_dtype(block.values, skipna=False)

if inferred_type == 'date':
raise TypeError(
Expand Down Expand Up @@ -1998,15 +1998,15 @@ def set_atom_string(self, block, block_items, existing_col, min_itemsize,
data = block.values

# see if we have a valid string type
inferred_type = lib.infer_dtype(data.ravel(), skipna=True)
inferred_type = lib.infer_dtype(data.ravel(), skipna=False)
if inferred_type != 'string':

# we cannot serialize this data, so report an exception on a column
# by column basis
for i, item in enumerate(block_items):

col = block.iget(i)
inferred_type = lib.infer_dtype(col.ravel(), skipna=True)
inferred_type = lib.infer_dtype(col.ravel(), skipna=False)
if inferred_type != 'string':
raise TypeError(
"Cannot serialize the column [%s] because\n"
Expand Down Expand Up @@ -2745,7 +2745,7 @@ def write_array(self, key, value, items=None):

# infer the type, warn if we have a non-string type here (for
# performance)
inferred_type = lib.infer_dtype(value.ravel(), skipna=True)
inferred_type = lib.infer_dtype(value.ravel(), skipna=False)
if empty_array:
pass
elif inferred_type == 'string':
Expand Down Expand Up @@ -4512,7 +4512,7 @@ def _convert_index(index, encoding=None, errors='strict', format_type=None):
if isinstance(index, MultiIndex):
raise TypeError('MultiIndex not supported here!')

inferred_type = lib.infer_dtype(index, skipna=True)
inferred_type = lib.infer_dtype(index, skipna=False)

values = np.asarray(index)

Expand Down Expand Up @@ -4745,7 +4745,7 @@ def __init__(self, table, where=None, start=None, stop=None):

# see if we have a passed coordinate like
try:
inferred = lib.infer_dtype(where, skipna=True)
inferred = lib.infer_dtype(where, skipna=False)
if inferred == 'integer' or inferred == 'boolean':
where = np.asarray(where)
if where.dtype == np.bool_:
Expand Down
2 changes: 1 addition & 1 deletion pandas/io/stata.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ def parse_dates_safe(dates, delta=False, year=False, days=False):
to_datetime(d['year'], format='%Y').astype(np.int64))
d['days'] = days // NS_PER_DAY

elif infer_dtype(dates, skipna=True) == 'datetime':
elif infer_dtype(dates, skipna=False) == 'datetime':
if delta:
delta = dates.values - stata_epoch
f = lambda x: \
Expand Down