Skip to content

Not all DateOffsets are comparable #8386

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
edrevo opened this issue Sep 25, 2014 · 4 comments
Closed

Not all DateOffsets are comparable #8386

edrevo opened this issue Sep 25, 2014 · 4 comments
Labels
API Design Error Reporting Incorrect or improved errors from pandas Frequency DateOffsets

Comments

@edrevo
Copy link

edrevo commented Sep 25, 2014

>>> from pandas.tseries.frequencies import to_offset as _to_offset
>>> _to_offset('D') < _to_offset('H')
False
>>> _to_offset('D') < _to_offset('W')
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-14-77799b586280> in <module>()
----> 1 _to_offset('D') < _to_offset('W')

C:\Anaconda\lib\site-packages\pandas\tseries\offsets.pyc in f(self, other)
   1873 def _tick_comp(op):
   1874     def f(self, other):
-> 1875         return op(self.delta, other.delta)
   1876 
   1877     return f

AttributeError: 'Week' object has no attribute 'delta'
>>> pd.show_versions()
INSTALLED VERSIONS
------------------
commit: None
python: 2.7.7.final.0
python-bits: 64
OS: Windows
OS-release: 8
machine: AMD64
processor: Intel64 Family 6 Model 42 Stepping 7, GenuineIntel
byteorder: little
LC_ALL: None
LANG: None

pandas: 0.14.0
nose: 1.3.3
Cython: 0.20.1
numpy: 1.8.1
scipy: 0.14.0
statsmodels: 0.5.0
IPython: 2.1.0
sphinx: 1.2.2
patsy: 0.2.1
scikits.timeseries: None
dateutil: 1.5
pytz: 2014.3
bottleneck: None
tables: 3.1.1
numexpr: 2.3.1
matplotlib: 1.3.1
openpyxl: 1.8.5
xlrd: 0.9.3
xlwt: 0.7.5
xlsxwriter: 0.5.5
lxml: 3.3.5
bs4: 4.3.1
html5lib: None
bq: None
apiclient: None
rpy2: None
sqlalchemy: 0.9.4
pymysql: None
psycopg2: None
@jreback
Copy link
Contributor

jreback commented Sep 26, 2014

I am not sure their is a guarantee of comparability between offsets anywhere. Have you seen and docs/code which indicate this?

e.g.

_to_offset('D') < _to_offset('30H') should be False but is True because its not comparing the correct things

so I suppose this is an issue, but what is the use case?

@jtratner
Copy link
Contributor

at the minimum, should raise some kind of Type or Value error saying that
they are incompatible, no?

On Fri, Sep 26, 2014 at 7:38 AM, jreback [email protected] wrote:

I am not sure their is a guarantee of comparability between offsets
anywhere. Have you seen and docs/code which indicate this?

e.g.

_to_offset('D') < _to_offset('30H') should be False but is True because
its not comparing the correct things

so I suppose this is an issue, but what is the use case?


Reply to this email directly or view it on GitHub
#8386 (comment).

@jreback
Copy link
Contributor

jreback commented Sep 26, 2014

@jtratner yeh I think that they should raise for now

@jreback jreback added the Error Reporting Incorrect or improved errors from pandas label Sep 26, 2014
@jreback jreback added this to the 0.15.1 milestone Sep 26, 2014
@edrevo
Copy link
Author

edrevo commented Sep 27, 2014

The use case is the following: I have a metric that can be calculated on different frequencies (daily, hourly, monthly). The thing is that a different filtering needs to happen depending on the frequency: if the metric is calculated hourly, then all data points after 18:00 or before 8:00 for a given day need to be filtered out. This cannot happen if the metric has been calculated daily, since the timestamps will look like 2014-09-27 00:00, so the filtering would effectively wipe out all data.

So basically I need to know, given a datetimeindex, if its frequency ir more os less granular than a day.

@jreback jreback modified the milestones: 0.16.0, Next Major Release Mar 6, 2015
@jbrockmendel jbrockmendel mentioned this issue Dec 19, 2017
39 tasks
@datapythonista datapythonista modified the milestones: Contributions Welcome, Someday Jul 8, 2018
@edrevo edrevo closed this as completed Mar 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Design Error Reporting Incorrect or improved errors from pandas Frequency DateOffsets
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants