Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/362.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用xlsxwriter时Python日期时间变为浮动_Python_Excel_Pandas_Dataframe_Xlsxwriter - Fatal编程技术网

使用xlsxwriter时Python日期时间变为浮动

使用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

下面是我在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':
        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文档中的和。

此问题需要编辑。您应该能够提供数据帧的示例,以及所需的预期输出和/或您面临的特定错误或问题。试着阅读如何写一个好的熊猫例子