I have a big data set that I need to date operation, and as it is taking too long, I was wondering if there is any other way to boost up the speed. Data frame looks like following:
Date, Month
2017-01-01, 0
2017-01-01, 1
2017-01-01, 2
I need to create another column that adds month column to date column, so it would look like following:
Date, Month, newDate
2017-01-01, 0, 2017-01-01
2017-01-01, 1, 2017-02-01
2017-01-01, 2, 2017-03-01
My current method is using apply function and relativedelta method like:
def newDateCalc(self, row):
return row[0] + relativedelta(months = row[1])
df['newDate'] = df[['Date', 'Month']].apply(lambda row: newDateCalc(row), axis = 1)
Thank you for your help in advance,