Skip to content

ERR: better message for HDFStore date query with non date columns #15492

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

Closed
chris-b1 opened this issue Feb 23, 2017 · 2 comments
Closed

ERR: better message for HDFStore date query with non date columns #15492

chris-b1 opened this issue Feb 23, 2017 · 2 comments
Labels
Error Reporting Incorrect or improved errors from pandas IO HDF5 read_hdf, HDFStore
Milestone

Comments

@chris-b1
Copy link
Contributor

When querying a HDFStore with a timestamp, on a column that (in my case, inadvertently) isn't a datetime, the error message isn't helpful; I think we can trap and show something better here.

df = pd.DataFrame({'date': ['2014-01-01', '2014-01-02'], 'values': [1, 2]})

df.to_hdf('store.h5', 'df', format='t', data_columns=['date'])

ts = pd.Timestamp('2014-01-01')

In [18]: pd.read_hdf('store.h5', 'df', where='date > ts')
  File "<string>", line 1
    (date > 1970-01-01 00:00:01.388556)
                  ^
SyntaxError: invalid token

pandas 0.19.2

@chris-b1 chris-b1 added Error Reporting Incorrect or improved errors from pandas IO HDF5 read_hdf, HDFStore labels Feb 23, 2017
@chris-b1 chris-b1 added this to the Next Major Release milestone Feb 23, 2017
@jreback
Copy link
Contributor

jreback commented Feb 23, 2017

what you don't like SyntaxError :<? (hahha)

@jreback jreback modified the milestones: 0.20.0, Next Major Release Mar 2, 2017
@jreback
Copy link
Contributor

jreback commented Mar 3, 2017

your change didn't fail any existing tests, interesting. ok thanks for the fix. merging.

@jreback jreback closed this as completed in 04e1168 Mar 3, 2017
AnkurDedania pushed a commit to AnkurDedania/pandas that referenced this issue Mar 21, 2017
closes pandas-dev#15492

Author: Chris <[email protected]>

Closes pandas-dev#15544 from chris-b1/hdf-dt-error and squashes the following commits:

8288dca [Chris] lint
7c7100d [Chris] expand test cases
946a48e [Chris] ERR: more strict HDFStore string comparison
213585f [Chris] CLN: remove timetuple type check
cc977f0 [Chris] BUG: syntax error in hdf query with ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Error Reporting Incorrect or improved errors from pandas IO HDF5 read_hdf, HDFStore
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants