Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/337.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
Python 使用pandas将边框添加到excel_Python_Pandas - Fatal编程技术网

Python 使用pandas将边框添加到excel

Python 使用pandas将边框添加到excel,python,pandas,Python,Pandas,我需要在我使用熊猫创建的数据框周围添加边框,如附图所示。下面是我的代码片段。如何做到这一点 [df = pd.DataFrame(data) df2=pd.DataFrame(exportFields) df2 = df2.transpose() # Create a Pandas Excel writer using XlsxWriter as the engine. writer = pd.ExcelWriter('C:/Users/roshni.j/Desktop/Clarivoy_doc

我需要在我使用熊猫创建的数据框周围添加边框,如附图所示。下面是我的代码片段。如何做到这一点

[df = pd.DataFrame(data)
df2=pd.DataFrame(exportFields)
df2 = df2.transpose()
# Create a Pandas Excel writer using XlsxWriter as the engine.
writer = pd.ExcelWriter('C:/Users/roshni.j/Desktop/Clarivoy_docs/Testing/pandas_simple.xlsx', engine='xlsxwriter')


# Convert the dataframe to an XlsxWriter Excel object.
df2.to_excel(writer, sheet_name='Sheet1',index=False, header=False,startcol=1, startrow=2)
df.to_excel(writer, sheet_name='Sheet1',index=False, header=False,startcol=1, startrow=3)


# Close the Pandas Excel writer and output the Excel file.
writer.save()

您需要为此()使用类似于StyleFrame的东西。纯pandas无法在Excel中绘制任何框架。

使用pandas中的
添加表格
方法,然后您可以对其进行样式设置。