datetime - Unexpected behavior from python's relativedelta -


i'm getting confusing result when using python's timestamps ,

my_timestamp

timestamp('2015-06-01 00:00:00')

my_timestamp + relativedelta(month = +4)

timestamp('2015-04-01 00:00:00')

naturally expected output timestamp('2015-10-01 00:00:00')

what correct way add "months" dates?


[edit]: i've since solved using following (in case in pandas has same problem):

print my_timestamp
print my_timestamp + dateoffset(months=4)

2015-06-01 00:00:00
2015-10-01 00:00:00

the issue using wrong keyword argument. want months instead of month.

per the documentation, month denotes absolute information (not relative) , replaces given information, noting. using months denotes relative information, , performs calculation you'd expect:

timestamp('2015-06-01 00:00:00') + relativedelta(months=4)  2015-10-01 00:00:00 

Comments

Popular posts from this blog

jOOQ update returning clause with Oracle -

java - Warning equals/hashCode on @Data annotation lombok with inheritance -

java - BasicPathUsageException: Cannot join to attribute of basic type -