-2

Here is the for loop using which I am writing my data frame in excel sheet

for i in range(1,len(sorted_tasks[sorted_tasks.columns[0]])):
    ls = list(sorted_tasks.loc[i])
    if sorted_tasks['Age'][i]>=10 and type_of_breach(sorted_tasks['Expected Delivery Date'][i]) != 'y':
        worksheet.write_row(i,0,ls,format_green)
    elif type_of_breach(sorted_tasks['Expected Delivery Date'][i])=='y' and sorted_tasks['Age'][i]>=10:
        worksheet.write_row(i,0,ls,format_orange)
    elif type_of_breach(sorted_tasks['Expected Delivery Date'][i])=='y':
        worksheet.write_row(i,0,ls,format_yellow)
    elif type_of_breach(sorted_tasks['Expected Delivery Date'][i])=='r':
        worksheet.write_row(i,0,ls,format_red)
    else:
        worksheet.write_row(i,0,ls,format_normal)

This is how I am getting it though the calculation are correct I want this to be in this format

jmcnamara
  • 38,196
  • 6
  • 90
  • 108
asingh
  • 56
  • 1
  • 5
  • This question needs to be edited. You should be able to provide a sample of your dataframe, and a desired expected output and/or the specific error or issue you are facing. Try reading [this post](https://stackoverflow.com/questions/20109391/how-to-make-good-reproducible-pandas-examples) on how to write a good pandas example – MattR Feb 22 '18 at 14:15

1 Answers1

0

Dates in Excel are represented by numbers with a format. If you don't supply a date format you just get a number/float.

It is hard to tell without a working program but you probably need to add a date format to your XlsxWriter code. See Working with Dates and Time and Default Date Formatting in the XlsxWriter docs for more information.

jmcnamara
  • 38,196
  • 6
  • 90
  • 108