Skip to content

Commit 2a3278c

Browse files
committed
TST: io/pytables.py tests now raise NotImplementedError for dtype==category
1 parent e6abfcf commit 2a3278c

File tree

2 files changed

+19
-13
lines changed

2 files changed

+19
-13
lines changed

pandas/io/pytables.py

+3
Original file line numberDiff line numberDiff line change
@@ -1773,6 +1773,9 @@ def set_atom(self, block, block_items, existing_col, min_itemsize,
17731773
raise TypeError(
17741774
"[unicode] is not implemented as a table column")
17751775

1776+
elif dtype == 'category':
1777+
raise NotImplementedError
1778+
17761779
# this is basically a catchall; if say a datetime64 has nans then will
17771780
# end up here ###
17781781
elif inferred_type == 'string' or dtype == 'object':

pandas/io/tests/test_pytables.py

+16-13
Original file line numberDiff line numberDiff line change
@@ -4349,25 +4349,28 @@ def test_query_with_nested_special_character(self):
43494349
tm.assert_frame_equal(expected, result)
43504350

43514351
def test_categorical(self):
4352-
try:
4352+
# FIXME
4353+
4354+
with ensure_clean_store(self.path) as store:
4355+
43534356
s = Series(Categorical(['a', 'b', 'b', 'a', 'a', 'c'], levels=['a','b','c','d']))
4354-
# FIXME: AttributeError: 'Categorical' object has no attribute 'T'
4355-
s.to_hdf(self.path, "cat_series_alone")
4356-
s2 = read_hdf(self.path, "cat_series_alone")
4357-
tm.assert_series_equal(s, s2)
4357+
4358+
self.assertRaises(NotImplementedError, store.append, 's', s, format='table')
4359+
#store.append('s', s, format='table')
4360+
#result = store.select('s')
4361+
#tm.assert_series_equal(s, result)
4362+
43584363
df = DataFrame({"s":s, "vals":[1,2,3,4,5,6]})
4359-
df.to_hdf(self.path, "cat_frame_alone")
4360-
df2 = read_hdf(self.path, "cat_frame_alone")
4361-
tm.assert_frame_equal(df, df2)
4364+
self.assertRaises(NotImplementedError, store.append, 'df', df, format='table')
4365+
#store.append('df', df, format='table')
4366+
#result = store.select('df')
4367+
#tm.assert_frame_equal(df, df2)
4368+
43624369
# Ok, this doesn't work yet
43634370
# FIXME: TypeError: cannot pass a where specification when reading from a Fixed format store. this store must be selected in its entirety
4364-
#result = read_hdf(hdf_file, "frame_alone", where = ['index>2'])
4371+
#result = store.select('df', where = ['index>2'])
43654372
#tm.assert_frame_equal(df[df.index>2],result)
43664373

4367-
finally:
4368-
safe_remove(self.path)
4369-
4370-
43714374
def _test_sort(obj):
43724375
if isinstance(obj, DataFrame):
43734376
return obj.reindex(sorted(obj.index))

0 commit comments

Comments
 (0)