首页 > 解决方案 > python代码工作正常但exe抛出groupby错误

问题描述

我有一个问题,但不确定它是否与创建 exe 或其他东西有关。

我的 python 代码通过 pycharm 可以正常工作,但是当我从中运行 exe 文件时,它给了我错误:

Traceback (most recent call last):
    '''
      File "threading.py", line 917, in _bootstrap_inner
      File "threading.py", line 865, in run
      File "KPICompilation.py", line 49, in thread_function
        df_by_date = merged_data.groupby("Date")
      File "pandas\core\frame.py", line 6727, in groupby
      File "pandas\core\groupby\groupby.py", line 568, in __init__
      File "pandas\core\groupby\grouper.py", line 811, in get_grouper
    KeyError: 'Date'
    '''

我通过这个 cmd 创建了 exe 文件:

pyinstaller --additional-hooks-dir=. --onefile Compilation.py

这是引发错误的行:

df_by_date = merged_data.groupby("Date")

根据我对此的简短研究...我尝试过strip()但似乎没有用

标签: pythonpandas-groupbypyinstaller

解决方案


推荐阅读