The relativedelta type, as defined by the datetutil module, is designed to be applied to an existing datetime and can replace specific components of that datetime, or represents an interval of time.
Questions tagged [relativedelta]
50 questions
0
votes
1 answer
Best way to accurately get the number of months between two dates spanning different years
I have the need to be able to accurately find the number of months between two dates even when they span different years. I have the below solution which I got from this StackOverflow thread but it fails at when the dates span different years.
works…

lennykioko
- 11
- 3
0
votes
2 answers
How to add interest to a bank account balance once a month?
I have to create a bankaccount class that has functions such as: deposit, withdraw, getbalance; all that beginner stuff. All very easy and I finished it no problem. However, there is a function called Interest that takes in an interest_rate where I…

mmerjem
- 11
- 1
0
votes
1 answer
How to ignore NA when applying relativedelta
I have to add 'N' no.of months in the date column and was trying to use this
function to help me to do so.
order_emis_full['calc_due_date']=order_emis_full['agreement_date'].apply(lambda x: x + relativedelta.relativedelta(months=1))
I keep…

Herge Bristol
- 11
- 4
0
votes
3 answers
Problems with adding +1 (period) and -1 day with dateutil's relativedelta
I'm getting a class typeerror using dateutil's relative delta. My code is here:
#import packages
import numpy as np
import pandas as pd
import datetime as dt
from dateutil.relativedelta import relativedelta
from pandas import DataFrame
from pandas…

user7038639
- 79
- 1
- 7
-1
votes
1 answer
How do I go about incrementing a datetime value by one month using 'relativedelta(months=1)' without affecting the numerical day value?
enter image description here
The code I wrote above works fine except I want the numerical day (%d) of the month to stay unchanged (30th) for all the months bar February (28th). The fact that the day value remains 28 after the month February is…

hareko
- 5
- 2