Need guidance on how I can format a value to date format in Pandas
before it prints out the value to an Excel sheet
.
I am new to Pandas
and had to edit an existing code when the values are output to an Excel sheet
.
After some conditional/functional calculations are done, the value is then output to Excel
.
My Current value seems to be in string format
which is not an Excel
friendly date format.
Output of the value looks like this :
Needed to format the output to the date format
I did try the options of strptime
, but as per my understanding, these values will also give the output in string format. the strange part is, I am not able to format the column in Excel
to date format using Excel
formatting option as well.
Thank you for your time and help.
My code is something like this:
def calculate(snumber,owner,reason):
#some if conditions and then
date11 = Date + relativedelta(months = 1)
return date11.strftime('%d %b %Y')
df['date1'] = df.apply(lambda x: calculate(x['snumber'], x['owner'], x['reason']), axis=1)