I have a CSV file that has a Year column (int) and a Month column (str).
| Year | MonthLong |
|---|---|
| 1984 | January |
| 1984 | January |
I'd like to have the last day of each month in a separate column (dd/mm/yy).
I've tried lots of dumb things (just learning and still trying too many of my excel work arounds) but am at a loss now.
months = {'January':1, 'February':2, 'March':3, 'April':4, 'May':5, 'June':6, 'July':7, 'August':8, 'September':9, 'October':10, 'November':11, 'December':12}
#Creates a column with month as a number
tax_cols['Month'] = tax_cols['MonthLong'].map(months)
#Adds a day column to get to_datetime to work - day is wrong
tax_cols['Day'] = tax_cols['MonthLong'].map(months)
#Creates a full date column - day is wrong
tax_cols['FullDate'] = pd.to_datetime(tax_cols[['Year', 'Month', 'Day']])
From here I have tried datetime/relativedelta and monthrange with no success. Any ideas how I can move this forward?