Skip to content
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

'infer_freq' can return timerule (WOM-5MON) that 'to_offset' does not support #9425

Closed
craustin opened this issue Feb 5, 2015 · 3 comments · Fixed by #9427
Closed

'infer_freq' can return timerule (WOM-5MON) that 'to_offset' does not support #9425

craustin opened this issue Feb 5, 2015 · 3 comments · Fixed by #9427
Labels
Frequency DateOffsets
Milestone

Comments

@craustin
Copy link

craustin commented Feb 5, 2015

import pandas as pd
index = [pd.Timestamp('2014-03-31 00:00:00'),
         pd.Timestamp('2014-06-30 00:00:00'),
         pd.Timestamp('2015-03-30 00:00:00'),
         pd.Timestamp('2015-06-29 00:00:00')]
freq = pd.infer_freq(index)  # WOM-5MON
pd.datetools.to_offset(freq)  # ValueError: Could not evaluate WOM-5MON

Instead of supporting WOM-5###, I think we can easily modify _get_wom_rule() to return None for this set of dates so it doesn't get inferred. Agree?

craustin pushed a commit to craustin/pandas that referenced this issue Feb 5, 2015
@jreback jreback added the Frequency DateOffsets label Feb 6, 2015
@jreback
Copy link
Contributor

jreback commented Feb 6, 2015

well the inferer is technically correct here. and the to_offset doesn't work for that offset (see #7985)

I think you could add a strict keyword that would tell the inferer how hard to try (e.g. only produce the default frequencies, don't get the more esoteric ones).

@craustin
Copy link
Author

craustin commented Feb 9, 2015

The problem comes up when pandas itself uses the inferred frequency here: https://github.com/pydata/pandas/blob/master/pandas/tseries/index.py#L823

If I go with your suggestion above, do you suggest I change the inferred_freq to strict?

@jreback
Copy link
Contributor

jreback commented Feb 12, 2015

well I think its better to have to_offset actually work with these frequencies (separately can be decided to infer this from data). I think we should normally NOT infer these special frequencies (IOW, I would be in favor of adding strict=True to give the option to not try to hard to infer these; and if it fails on the inference then it returns None as the result frequency.)

@jreback jreback added this to the 0.17.0 milestone May 29, 2015
craustin pushed a commit to craustin/pandas that referenced this issue May 30, 2015
craustin pushed a commit to craustin/pandas that referenced this issue May 30, 2015
shoyer added a commit that referenced this issue May 30, 2015
ENH: Don't infer WOM-5MON if we don't support it (#9425)
@jorisvandenbossche jorisvandenbossche modified the milestones: 0.17.0, 0.16.2 Jun 2, 2015
cgevans added a commit to cgevans/pandas that referenced this issue Jun 5, 2015
* https://github.com/pydata/pandas: (26 commits)
  disable some deps on 3.2 build
  Fix meantim typo
  DOC: use current ipython in doc build
  PERF: write basic datetimes faster pandas-dev#10271
  TST: fix for bottleneck >= 1.0 nansum behavior, xref pandas-dev#9422
  add numba example to enhancingperf.rst
  BUG: SparseSeries constructor ignores input data name
  BUG: Raise TypeError only if key DataFrame is not empty pandas-dev#10126
  ENH: groupby.apply for Categorical should preserve categories (closes pandas-dev#10138)
  DOC: add in whatsnew/0.17.0.txt
  DOC: move whatsnew from 0.17.0 -> 0.16.2
  BUG:  Holiday(..) with both offset and observance raises NotImplementedError pandas-dev#10217
  BUG: Index.union cannot handle array-likes
  BUG: SparseSeries.abs() resets name
  BUG: Series arithmetic methods incorrectly hold name
  ENH: Don't infer WOM-5MON if we don't support it (pandas-dev#9425)
  BUG: Series.align resets name when fill_value is specified
  BUG: GroupBy.get_group raises ValueError when group key contains NaT
  Close mysql connection in TestXMySQL to prevent tests freezing
  BUG: plot doesnt default to matplotlib axes.grid setting (pandas-dev#9792)
  ...
yarikoptic added a commit to neurodebian/pandas that referenced this issue Jul 2, 2015
* commit 'v0.16.1-97-gbc7d48f': (56 commits)
  disable some deps on 3.2 build
  Fix meantim typo
  DOC: use current ipython in doc build
  PERF: write basic datetimes faster pandas-dev#10271
  TST: fix for bottleneck >= 1.0 nansum behavior, xref pandas-dev#9422
  add numba example to enhancingperf.rst
  BUG: SparseSeries constructor ignores input data name
  BUG: Raise TypeError only if key DataFrame is not empty pandas-dev#10126
  ENH: groupby.apply for Categorical should preserve categories (closes pandas-dev#10138)
  DOC: add in whatsnew/0.17.0.txt
  DOC: move whatsnew from 0.17.0 -> 0.16.2
  BUG:  Holiday(..) with both offset and observance raises NotImplementedError pandas-dev#10217
  BUG: Index.union cannot handle array-likes
  BUG: SparseSeries.abs() resets name
  BUG: Series arithmetic methods incorrectly hold name
  ENH: Don't infer WOM-5MON if we don't support it (pandas-dev#9425)
  BUG: Series.align resets name when fill_value is specified
  BUG: GroupBy.get_group raises ValueError when group key contains NaT
  Close mysql connection in TestXMySQL to prevent tests freezing
  BUG: plot doesnt default to matplotlib axes.grid setting (pandas-dev#9792)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Frequency DateOffsets
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants