Skip to content

Fix mistake in Pytables querying with numpy scalar value. Fixes #11283 #11291

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

Merged
merged 1 commit into from
Oct 13, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc/source/whatsnew/v0.17.1.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ Bug Fixes

- Bug in ``.to_latex()`` output broken when the index has a name (:issue: `10660`)
- Bug in ``HDFStore.append`` with strings whose encoded length exceded the max unencoded length (:issue:`11234`)

- Bug in ``HDFStore.select`` when comparing with a numpy scalar in a where clause (:issue:`11283`)



Expand Down
2 changes: 1 addition & 1 deletion pandas/computation/pytables.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def conform(self, rhs):
""" inplace conform rhs """
if not com.is_list_like(rhs):
rhs = [rhs]
if hasattr(self.rhs, 'ravel'):
if isinstance(rhs, np.ndarray):
rhs = rhs.ravel()
return rhs

Expand Down
12 changes: 12 additions & 0 deletions pandas/io/tests/test_pytables.py
Original file line number Diff line number Diff line change
Expand Up @@ -3049,6 +3049,18 @@ def test_select_dtypes(self):
result = store.select(
'df4', where='values>2.0')
tm.assert_frame_equal(expected, result)

# test selection with comparison against numpy scalar
# GH 11283
with ensure_clean_store(self.path) as store:
df = tm.makeDataFrame()

expected = df[df['A']>0]

store.append('df', df, data_columns=True)
np_zero = np.float64(0)
result = store.select('df', where=["A>np_zero"])
tm.assert_frame_equal(expected, result)

def test_select_with_many_inputs(self):

Expand Down