【发布时间】:2022-12-03 03:45:19
【问题描述】:
我们正在尝试使用 Python 代码创建一个包含嵌套数据的新 Excel 文件。这是供参考的代码:
`import glob
import pandas as pd
import re
import openpyxl
dp = pd.read_excel("UnpredictableDataMerge.xlsx", sheet_name ="Sheet1")
line_numbers = [4, 7]
print("Heey, we read")
dp_max = dp.groupby(['Subject', 'Date & Time', 'Trees Again', 'DifficultyLevel', 'Block', 'UpdatevsNonupdate', 'responsetimerecodeforACC', 'Nonupdate', 'Update'], sort=False).max()
dp_max = dp_max[["Total Training Time"]]
print("This worked. Good start. Yaaaay.s")
dp_max.to_excel('unpredictable_grouped_max_heregoesnothing.xlsx', index=True)
print("This worked. Yaaaay.s")
dp['Signal_Detection2'] = dp.loc[:, 'Signal_Detection']
dp_count = dp.groupby(['Subject', 'Signal_Detection'], sort=False).count()[["Signal_Detection2"]]
dp_count.to_excel('unpredictable_grouped_signal_count_heregoesnothing.xlsx', index=True)
Unexpected exception formatting exception. Falling back to standard exception
Output exceeds the size limit. Open the full output data in a text editor
Traceback (most recent call last):
File "C:\Users\mxa210135\AppData\Roaming\Python\Python38\site-packages\IPython\core\interactiveshell.py", line 3433, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-9-853a8bf5b14e>", line 5, in <module>
dp = pd.read_excel("UnpredictableDataMerge.xlsx", sheet_name ="Sheet1")`
上面的代码是我们已经尝试过的,并且它以前工作过。我们只添加了“Trees Again”变量和“UpdatevsNonupdate”、“responsetimerecodeforACC”、“Nonupdate”,最后是“Update”。 如果需要更多信息,请告诉我,我会很乐意提供。
我们尝试将大文件分成两半并在两者上运行代码,但它不起作用并给了我们相同的错误消息。
【问题讨论】:
-
请修剪您的代码,以便更容易找到您的问题。按照这些指南创建一个minimal reproducible example。
标签: python excel database output data-analysis