Skip to content

MonthOffset() gives increase of 1 day instead of 1 month #7707

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
jorisvandenbossche opened this issue Jul 9, 2014 · 9 comments
Closed

MonthOffset() gives increase of 1 day instead of 1 month #7707

jorisvandenbossche opened this issue Jul 9, 2014 · 9 comments
Labels

Comments

@jorisvandenbossche
Copy link
Member

From #7375 (comment):

In [67]: from pandas.tseries import offsets

In [69]: d = pd.Timestamp('2014-01-01 09:00:00')

In [70]: d + offsets.MonthOffset()
Out[70]: Timestamp('2014-01-02 09:00:00')

In [71]: offsets.MonthOffset().apply(d)
Out[71]: Timestamp('2014-01-02 09:00:00')

In [72]: d + offsets.Day()
Out[72]: Timestamp('2014-01-02 09:00:00')
@jreback jreback added this to the 0.15.0 milestone Jul 9, 2014
@jreback
Copy link
Contributor

jreback commented Jul 9, 2014

as noted in #7375. This (and YearOffset), need an apply implementation as they are using the DateOffset one (which is day-based). The constructor is ok.

doc-string should be expanded as well.

@jreback jreback added the Docs label Jul 9, 2014
@hayd
Copy link
Contributor

hayd commented Aug 9, 2014

Also noticed this with #7599, confusing.

I need to fix up #6318 in 2.6 (grumble grumble), I don't recall if that addressed this... ? (maybe not...)

@jreback
Copy link
Contributor

jreback commented Aug 9, 2014

you need to specify month=1 and it will work
(it's interpreting the first arg as the day keyword)

@hayd
Copy link
Contributor

hayd commented Aug 9, 2014

Hmmm, + seems to set the month:

In [11]: pd.Timestamp.now()
Out[11]: Timestamp('2014-08-09 13:59:37.263338')

In [12]: pd.Timestamp.now() + pd.offsets.MonthOffset(month=1)
Out[12]: Timestamp('2014-01-09 13:59:39.467444')

In [13]: pd.Timestamp.now() + pd.offsets.MonthOffset(month=2)
Out[13]: Timestamp('2014-02-09 13:59:41.586575')

@jreback jreback modified the milestones: 0.15.1, 0.15.0 Sep 9, 2014
@jreback jreback modified the milestones: 0.16.0, Next Major Release Mar 6, 2015
@jbrockmendel
Copy link
Member

This is semi-closed by #18375. MonthOffset should never be used directly, will now raise NotImplementedError if you try the addition or apply in the OP. MonthOffset, QuarterOffset, YearOffset are base classes that should probably be privatized.

Or they could be adapted so that the base classes are non-anchored and just increment by 1, 3, and 12 months respectively.

@jreback
Copy link
Contributor

jreback commented Nov 29, 2017

@jbrockmendel ok, can you add this to the API breaking section

and add some tests that these now raise NotImplementedError (use #18375 issue).

@jreback jreback modified the milestones: Next Major Release, 0.22.0 Nov 29, 2017
@jbrockmendel
Copy link
Member

Out of town for a couple days, will address then when no longer typing with thumbs

@jbrockmendel jbrockmendel mentioned this issue Dec 19, 2017
39 tasks
@jorisvandenbossche jorisvandenbossche modified the milestones: 0.23.0, Next Major Release Mar 29, 2018
@ron819
Copy link

ron819 commented Nov 27, 2018

Any chance this will be fixed for the next release?

euronion added a commit to euronion/atlite that referenced this issue Dec 18, 2018
apply() on object pandas.offsets.MonthOffsets() became obsolete, see pandas-dev/pandas#7707 (comment).
Caused NotImplementedErrors with SARAH and ERA5 cutouts.
euronion added a commit to euronion/atlite that referenced this issue Dec 18, 2018
apply() on object pandas.offsets.MonthOffsets() became obsolete, see pandas-dev/pandas#7707 (comment).
Caused NotImplementedErrors with SARAH and ERA5 cutouts.
euronion added a commit to euronion/atlite that referenced this issue Jan 23, 2019
apply() on object pandas.offsets.MonthOffsets() became obsolete, see pandas-dev/pandas#7707 (comment)

setup: set pandas version requirement.
@mroeschke
Copy link
Member

Looks like this has been effectively privatized. Going to close.

In [4]: In [70]: d + offsets.MonthOffset()
   ...:
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-4-c6cd081d9308> in <module>
----> 1 d + offsets.MonthOffset()

AttributeError: module 'pandas.tseries.offsets' has no attribute 'MonthOffset'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants