-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: Categorical data fails to load from hdf when all columns are NaN #18652
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 8 commits
3f07908
7a4f93a
8540a4a
928c258
b3766f7
52dc141
ea89a7c
551f0a2
e6aad40
7cf7336
a69ea02
538e7fe
b2ac7c4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4928,6 +4928,23 @@ def test_categorical_conversion(self): | |
result = read_hdf(path, 'df', where='obsids=B') | ||
tm.assert_frame_equal(result, expected) | ||
|
||
def test_categorical_nan_only_columns(self): | ||
# GH18413 | ||
# Check that read_hdf with categorical columns with NaN-only values can | ||
# be read back. | ||
df = pd.DataFrame({ | ||
'a': ['a', 'b', 'c', np.nan], | ||
'b': [np.nan, np.nan, np.nan, np.nan], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you add another column with an array like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done, seems to work fine. |
||
'c': [1, 2, 3, 4] | ||
}) | ||
df['a'] = df.a.astype('category') | ||
df['b'] = df.b.astype('category') | ||
expected = df | ||
with ensure_clean_path(self.path) as path: | ||
df.to_hdf(path, 'df', format='table', data_columns=True) | ||
result = read_hdf(path, 'df') | ||
tm.assert_frame_equal(result, expected) | ||
|
||
def test_duplicate_column_name(self): | ||
df = DataFrame(columns=["a", "a"], data=[[0, 0]]) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug when reading ......in a
:class:`HDFStore`
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, done.