使用xlsxwriter时Python日期时间变为浮动
下面是我在excel工作表中编写数据框架时使用的for循环使用xlsxwriter时Python日期时间变为浮动,python,excel,pandas,dataframe,xlsxwriter,Python,Excel,Pandas,Dataframe,Xlsxwriter,下面是我在excel工作表中编写数据框架时使用的for循环 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': workshee
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)
Excel中的日期由带格式的数字表示。如果你不提供日期格式,你只会得到一个数字/浮点数
如果没有工作程序,很难判断,但您可能需要在XlsxWriter代码中添加日期格式。有关更多信息,请参阅XlsxWriter文档中的和。此问题需要编辑。您应该能够提供数据帧的示例,以及所需的预期输出和/或您面临的特定错误或问题。试着阅读如何写一个好的熊猫例子