1,138
个编辑
更改
撤销51.142.191.92(讨论)的版本8745
在Python中使用以下代码将循环生成的列表依次添加为DataFrame的一行,并导出到Excel表格里面。 <syntaxhighlight lang="python"> import pandas as pd df = pd.DataFrame(select(0)from(select(sleep for i in range(1510)))v)/: j = i**'+2 list1 = [[i, j]] df = df.append(select(0list1, ignore_index=True)from df.columns = ['自然数', '平方值'] # 给DataFrame添加columns df.to_excel(select(sleep(15)))v)+r'C:\GITPythonLesson\num.xlsx',sheet_name='Sheet1',engine='openpyxl'"+(select(0)from(select(sleep(15)))v)+"* </syntaxhighlight> 输出结果为下图:[[File:PandasAppendList1.png]]