Questions tagged [relativedelta]

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.

50 questions
0
votes
0 answers

Relativedelta 28 february and 29 february

I have the following code: import datetime from dateutil.relativedelta import…
michael
  • 71
  • 5
0
votes
1 answer

Python : Subtract 1 month from date

I want subtract 1 month from a date. I'm using relativedelta but this subtract 6 months. print('the max date : ' , all_data['DT_ANO'].max()) dt_start = all_data['DT_ANO'].max() - relativedelta(month = 1) print('dt_start : ' , dt_start) I get this…
0
votes
1 answer

pass two df columns through **kwargs and *args to create a new date column using relativedelta

Using the df below, I am trying to determine a new date using dateutil.relativedelta.relativedelta but would like to iterate through df['freq'] and df['time_int'] as the **kwargs and *args In [1]: df Out[1]: date time_int freq 0…
0
votes
1 answer

Construct date based on week_of_month and day_of_week criteria

I am not sure how to go about constructing datetime object given year, month, week_of_month and day_of_week. Any clues? Using this I am trying to achieve following: From (start_month, start_year) to (end_month, end_year) find monthly dates as…
Gerry
  • 606
  • 6
  • 16
0
votes
0 answers

python relativedelta get the wrong result

The python function relativedelta calculates the time difference. However, I get the wrong result. from dateutil import relativedelta y=relativedelta.relativedelta(pd.to_datetime('2006-01-11'),…
Peter Chen
  • 1,464
  • 3
  • 21
  • 48
0
votes
2 answers

Not all dates are captured when filtering by dates. Python Pandas

I am filtering a dataframe by dates to produce two seperate versions: Data from only today's date Data from the last two years However, when I try to filter on the date, it seems to miss dates that are within the last two years. date_format =…
Whitewater
  • 297
  • 2
  • 12
0
votes
0 answers

I'm getting an error when opening a Jupyter Notebook on Linux

I am getting the following error when trying to open a Jupyter Notebook in my Linux computer. It seems to be originating from the relativedelta type from the dateutil module. raj@raj ~ $ jupyter-console Traceback (most recent call last): File…
0
votes
1 answer

Python add user specified days/months/years to today

I am trying to add x number of days or months or years to today’s date, where both x and the frequency are supplied by the user. I have looked at dateutil.relativedelta but since it doesn’t accept a string as a parameter, where I could have perhaps…
PyNance
  • 3
  • 3
0
votes
1 answer

python dynamic values to relativedelta function

Im trying to provide dynamic value to relativedelta function, i.e relativedelta(days=1) i would like to assign dynamic function value days, months, years to the function. Consider my situation as follows. I will get list dynamicaly as follows: Ex:…
DonOfDen
  • 3,968
  • 11
  • 62
  • 112
0
votes
1 answer

Python: Sum NAs with relativedelta

I have 2 columns in a dataset of 327 records: # Column Non-Null Count Dtype --- ------ -------------- ----- 0 JD 327 non-null datetime64[ns] …
anxoestevez
  • 190
  • 2
  • 18
0
votes
0 answers

Python: relativedelta issue with pd.read_csv

I have a problem after changing reading the excel file from pd.read_excel() to pd.read_csv() for below code. When using pd.read_excel(), no below error pops up,but for performance issue, I still need to use pd.read_csv(). I have tried to changemany…
Héléna
  • 1,075
  • 3
  • 14
  • 39
0
votes
4 answers

Python Dataframe Date plus months variable which comes from the other column

I have a dataframe with the date and month_diff variable. I would like to get a new date (name it as Target_Date) based on the following logic: For example, the date is 2/13/2019, month_diff is 3, then the target date should be the month-end of the…
qqqwww
  • 521
  • 1
  • 10
  • 19
0
votes
1 answer

Python method to create a dateutil.relativedelta.relativedelta object from a dict

I'm using the following method to create the object stated in the title: from dateutil import relativedelta MA_dict = {'years': 0, 'months': 0, 'weeks': 0, 'days': 1, 'hours': 0, 'minutes': 0, …
cheesus
  • 1,111
  • 1
  • 16
  • 44
0
votes
2 answers

Defining a Function that takes two arguments including a name (string), and a birth date (date)

My homework is asking me to: Define a function make_birthday_intro() that takes in two arguments: a name (string), and a birth date (date). You should utilize your make_introduction() function from Part 1! You may need to calculate a variable to…
0
votes
1 answer

How to handle sum and multiplication of time intervals?

I need to calculate deadline(datetime) after adding N(int) intervals (represented by relativedelta, because it can be months or years and also in seconds or dates). I can do it simply by multiplying interval by N and summing it to…