You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In [1]: importpandasaspdIn [2]: df=pd.DataFrame(index=pd.date_range(start='2010-01-23', periods=1000, freq='min'), data={'foo': pd.np.random.rand(1000)})
In [3]: df.resample('h').mean().tail()
Out[3]:
foo2010-01-2312:00:000.4779972010-01-2313:00:000.4882942010-01-2314:00:000.4260952010-01-2315:00:000.5490812010-01-2316:00:000.466148In [4]: df.resample('h', label='right').mean().tail()
Out[4]:
foo2010-01-2313:00:000.4779972010-01-2314:00:000.4882942010-01-2315:00:000.4260952010-01-2316:00:000.5490812010-01-2317:00:000.466148In [5]:
In [5]: df.resample('h', label='right_wrong').mean().tail()
Out[5]:
foo2010-01-2312:00:000.4779972010-01-2313:00:000.4882942010-01-2314:00:000.4260952010-01-2315:00:000.5490812010-01-2316:00:000.466148# The last command should fail!
Problem description
Recently (and maybe many times before without noticing...) I mistyped the string passed as kwarg label in resample, e.g. df.resample('5min', label='rigth') and wondered later why the alignment of my resampled data with the raw data was wrong. It turns out that the actual string passed as kwarg label is never checked to be either left or right. Hence, if it is
Is this on purpose, or should this be fixed?
If yes, a check could be inserted here. Or maybe deeper in the class hierarchy? Maybe other kwargs, like closed could also be affected.
jreback
changed the title
resample() silently ignores misstyped str kwargs, e.g. for label
resample() silently ignores misstyped str kwargs, e.g. for label
Jan 18, 2018
Code Sample, a copy-pastable example if possible
Problem description
Recently (and maybe many times before without noticing...) I mistyped the string passed as kwarg
label
inresample
, e.g.df.resample('5min', label='rigth')
and wondered later why the alignment of my resampled data with the raw data was wrong. It turns out that the actual string passed as kwarglabel
is never checked to be eitherleft
orright
. Hence, if it isIs this on purpose, or should this be fixed?
If yes, a check could be inserted here. Or maybe deeper in the class hierarchy? Maybe other kwargs, like
closed
could also be affected.If I get a pointer I could come up with a PR.
Output of
pd.show_versions()
The text was updated successfully, but these errors were encountered: