-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: syntax error in hdf query with ts #15544
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 2 commits
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 |
---|---|---|
|
@@ -5080,6 +5080,25 @@ def test_query_long_float_literal(self): | |
expected = df.loc[[1], :] | ||
tm.assert_frame_equal(expected, result) | ||
|
||
def test_query_ts_string_column(self): | ||
# GH 15492 | ||
df = pd.DataFrame({'date': ['2014-01-01', '2014-01-02'], | ||
'real_date': date_range('2014-01-01', periods=2), | ||
'values': [1, 2]}, | ||
columns=['date', 'real_date', 'values']) | ||
|
||
ts = pd.Timestamp('2014-01-01') # noqa | ||
|
||
with ensure_clean_store(self.path) as store: | ||
store.append('test', df, format='table', data_columns=True) | ||
|
||
result = store.select('test', where='date > ts') | ||
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. hmm, though on 2nd thought. shouldn't this raise? e.g. we are passing a string column and a datelike. (and we know the dtypes here). A datetimelike cannot be compared against anything but a datetime column by-definition. 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. That's a good point. Right now we are really liberal in terms of comparison to string columns - (maybe due to pytables?) - basically anything that has a repr - none of the following raise either. pd.read_hdf('store.h5', 'df', where='str_col > 2.2')
pd.read_hdf('store.h5', 'df', where='str_col > True')
class O:
pass
o = O()
pd.read_hdf('store.h5', 'df', where='str_col > o') 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. I'd be fine with all of those raising. 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. yeah I would be fine with being more strict. At the very least it would raise rather than return an empty result. Prob need a few test cases...... |
||
self.assertTrue(result.empty) | ||
|
||
result = store.select('test', where='real_date > ts') | ||
expected = df.loc[[1], :] | ||
tm.assert_frame_equal(expected, result) | ||
|
||
|
||
class TestHDFComplexValues(Base): | ||
# GH10447 | ||
|
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.
@jreback - any idea what this was supposed to be doing? This doesn't impact any tested behavior and not sure it ever would have worked.
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.
this was some really old compat IIRC. (or maybe just copied it from somewhere :>)
improving test coverage by deletions!
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.
yeah that isn't hit at all in the tests
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.
there is another reference to
timetuple
in that same file, you can prob take that out too.