Skip to content

Commit cc977f0

Browse files
committed
BUG: syntax error in hdf query with ts
1 parent b94186d commit cc977f0

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

pandas/computation/pytables.py

-4
Original file line numberDiff line numberDiff line change
@@ -188,10 +188,6 @@ def stringify(value):
188188
if v.tz is not None:
189189
v = v.tz_convert('UTC')
190190
return TermValue(v, v.value, kind)
191-
elif (isinstance(v, datetime) or hasattr(v, 'timetuple') or
192-
kind == u('date')):
193-
v = time.mktime(v.timetuple())
194-
return TermValue(v, pd.Timestamp(v), kind)
195191
elif kind == u('timedelta64') or kind == u('timedelta'):
196192
v = _coerce_scalar_to_timedelta_type(v, unit='s').value
197193
return TermValue(int(v), v, kind)

pandas/tests/io/test_pytables.py

+19
Original file line numberDiff line numberDiff line change
@@ -5080,6 +5080,25 @@ def test_query_long_float_literal(self):
50805080
expected = df.loc[[1], :]
50815081
tm.assert_frame_equal(expected, result)
50825082

5083+
def test_query_ts_string_column(self):
5084+
# GH 15492
5085+
df = pd.DataFrame({'date': ['2014-01-01', '2014-01-02'],
5086+
'real_date': date_range('2014-01-01', periods=2),
5087+
'values': [1, 2]},
5088+
columns=['date', 'real_date', 'values'])
5089+
5090+
ts = pd.Timestamp('2014-01-01') # noqa
5091+
5092+
with ensure_clean_store(self.path) as store:
5093+
store.append('test', df, format='table', data_columns=True)
5094+
5095+
result = store.select('test', where='date > ts')
5096+
self.assertTrue(result.empty)
5097+
5098+
result = store.select('test', where='real_date > ts')
5099+
expected = df.loc[[1], :]
5100+
tm.assert_frame_equal(expected, result)
5101+
50835102

50845103
class TestHDFComplexValues(Base):
50855104
# GH10447

0 commit comments

Comments
 (0)