Skip to content

Commit 4f0325d

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

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

doc/source/whatsnew/v0.17.0.txt

+2
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,5 @@ Performance Improvements
5757

5858
Bug Fixes
5959
~~~~~~~~~
60+
61+
- 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)