Skip to content

Tag: datetime

MyPy complains about datetime difference

MyPy complains about the line of code where bar is assigned the difference of two datetimes. The type of foo is datetime.timedelta. The error message from MyPy is “int not callable”. What am I missing? Answer This turned out to be a known issue. For details, see the following: https://github.com/p…

How can I fix the list index out of range problem?

So I wanna fill NaN value of the pay date with the date one month after the join date. Join date Payday1 Okt’10 NaN Des’10 NaN My expectation output is: Join date Payday1 Okt’10 Nov’10 Des’10 Jan’11 I try this code: This code is error in this code month=months[months.index(…

convert month of dates into sequence

i want to combine months from years into sequence, for example, i have dataframe like this: i want to sequence the months of the date. the desired output is: which means feb’15 is the first month in the date list and jan’2016 is the 12th month after feb’2015 Answer If your date column is a d…