Skip to content

Fix invalid relativedelta_kwds #19398

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

Merged
merged 9 commits into from
Jul 20, 2018
Prev Previous commit
Next Next commit
add params to docstring
  • Loading branch information
jbrockmendel committed Feb 1, 2018
commit 51ec9ed64ac6777cb4a63c95df25bbeb24391d3e
23 changes: 23 additions & 0 deletions pandas/tseries/offsets.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,29 @@ def __add__(date):
date + BDay(0) == BDay.rollforward(date)

Since 0 is a bit weird, we suggest avoiding its use.

Parameters
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

correct, can you separate this into 2 subsections and make clear the different behavior (via an example)

In [1]: t = pd.Timestamp('20170101 09:10:11')

# operate with the value
In [3]: t + DateOffset(years=2018)
Out[3]: datetime.datetime(4035, 1, 1, 9, 10, 11)

In [5]: t + DateOffset(seconds=1)
Out[5]: Timestamp('2017-01-01 09:10:12')

# set the value
In [6]: t + DateOffset(second=1)
Out[6]: Timestamp('2017-01-01 09:10:01')

In [8]: t + DateOffset(month=1)
Out[8]: Timestamp('2017-01-01 09:10:11')

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is an issue to revisit this (IOW we should have 2 different offsets for this different behaviors)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. The docstring is already pretty big and likely to get much bigger. Is there somewhere else part of it should go?

there is an issue to revisit this (IOW we should have 2 different offsets for this different behaviors)

Yah, IIRC there was a suggestion to have __new__ dispatch some special cases to Tick, MonthOffset, etc. I'm planning to take a swing at that after the immutabilization since __new__ and cython are tricky.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't make it long, make it wide instead (its a bit non-standard ok)

n : int, default 1
normalize : bool, default False

Parameters that ADD to the offset
----------------------------------
years, months, ....

Parameters that REPLACE the offset value
-----------
year, month

----------
n : int (default 1)
normalize : bool (default False)
years : int or None
months : int or None
weeks : int or None
days : int or None
hours : int or None
minutes : int or None
seconds : int or None
microseconds : int or None
nanoseconds : int or None
year : int or None
month : int or None
day : int or None
weekday : int or None
hour : int or None
minute : int or None
second : int or None
microsecond : int or None
nanosecond : int or None
"""
_use_relativedelta = False
_adjust_dst = False
Expand Down