Skip to content

Commit 7fc3434

Browse files
jrebackAnkurDedania
authored andcommitted
TST: don't catch, but supress warnings in panel4d/panelnd (pandas-dev#15705)
1 parent 9630d4c commit 7fc3434

File tree

7 files changed

+210
-235
lines changed

7 files changed

+210
-235
lines changed

pandas/core/categorical.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -550,8 +550,8 @@ def _validate_categories(cls, categories, fastpath=False):
550550
# we don't allow NaNs in the categories themselves
551551

552552
if categories.hasnans:
553-
# NaNs in cats deprecated in 0.17,
554-
# remove in 0.18 or 0.19 GH 10748
553+
# NaNs in cats deprecated in 0.17
554+
# GH 10748
555555
msg = ('\nSetting NaNs in `categories` is deprecated and '
556556
'will be removed in a future version of pandas.')
557557
warn(msg, FutureWarning, stacklevel=3)

pandas/io/pytables.py

+15-3
Original file line numberDiff line numberDiff line change
@@ -2097,7 +2097,17 @@ def convert(self, values, nan_rep, encoding):
20972097

20982098
# we have a categorical
20992099
categories = self.metadata
2100-
self.data = Categorical.from_codes(self.data.ravel(),
2100+
codes = self.data.ravel()
2101+
2102+
# if we have stored a NaN in the categories
2103+
# then strip it; in theory we could have BOTH
2104+
# -1s in the codes and nulls :<
2105+
mask = isnull(categories)
2106+
if mask.any():
2107+
categories = categories[~mask]
2108+
codes[codes != -1] -= mask.astype(int).cumsum().values
2109+
2110+
self.data = Categorical.from_codes(codes,
21012111
categories=categories,
21022112
ordered=self.ordered)
21032113

@@ -3407,10 +3417,12 @@ def create_axes(self, axes, obj, validate=True, nan_rep=None,
34073417
if existing_table is not None:
34083418
indexer = len(self.non_index_axes)
34093419
exist_axis = existing_table.non_index_axes[indexer][1]
3410-
if append_axis != exist_axis:
3420+
if not array_equivalent(np.array(append_axis),
3421+
np.array(exist_axis)):
34113422

34123423
# ahah! -> reindex
3413-
if sorted(append_axis) == sorted(exist_axis):
3424+
if array_equivalent(np.array(sorted(append_axis)),
3425+
np.array(sorted(exist_axis))):
34143426
append_axis = exist_axis
34153427

34163428
# the non_index_axes info

0 commit comments

Comments
 (0)