Skip to content

Commit a01d8c0

Browse files
committed
Check for non-zero length frame on success cases and added a release note
1 parent b8ebaf9 commit a01d8c0

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

doc/source/whatsnew/v0.17.0.txt

+1-2
Original file line numberDiff line numberDiff line change
@@ -66,5 +66,4 @@ Bug Fixes
6666
- Bug in ``Timestamp``'s' ``microsecond``, ``quarter``, ``dayofyear``, ``week`` and ``daysinmonth`` properties return ``np.int`` type, not built-in ``int``. (:issue:`10050`)
6767
- Bug in ``NaT`` raises ``AttributeError`` when accessing to ``daysinmonth``, ``dayofweek`` properties. (:issue:`10096`)
6868

69-
70-
69+
- Bug in ``DataFrame.to_hdf()`` where table format would raise a seemingly unrelated error for invalid (non-string) column names. This is now explicitly forbidden. (:issue:`9057`)

pandas/io/tests/test_pytables.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -4621,8 +4621,6 @@ def test_to_hdf_with_object_column_names(self):
46214621
# GH9057
46224622
# Writing HDF5 table format should only work for string-like
46234623
# column types
4624-
def column_index_data_frame(index):
4625-
return DataFrame(np.random.randn(10,2), columns=index(2))
46264624

46274625
types_should_fail = [ tm.makeIntIndex, tm.makeFloatIndex,
46284626
tm.makeDateIndex, tm.makeTimedeltaIndex,
@@ -4635,7 +4633,7 @@ def column_index_data_frame(index):
46354633
types_should_fail.append(tm.makeUnicodeIndex)
46364634

46374635
for index in types_should_fail:
4638-
df = column_index_data_frame(index)
4636+
df = DataFrame(np.random.randn(10, 2), columns=index(2))
46394637
with ensure_clean_path(self.path) as path:
46404638
with self.assertRaises(ValueError,
46414639
msg="cannot have non-object label DataIndexableCol"):
@@ -4645,6 +4643,8 @@ def column_index_data_frame(index):
46454643
df = DataFrame(np.random.randn(10, 2), columns=index(2))
46464644
with ensure_clean_path(self.path) as path:
46474645
df.to_hdf(path, 'df', format='table', data_columns=True)
4646+
result = pd.read_hdf(path, 'df', where="index = [{0}]".format(df.index[0]))
4647+
assert(len(result))
46484648

46494649

46504650
def _test_sort(obj):

0 commit comments

Comments
 (0)