我正在尝试使用熊猫将文件夹中的多个excel文件合并为一个,而iam遇到了以上错误
import os
import pandas as pd
import numpy as np
path = os.getcwd("C:/Users/SHARAN/Desktop/EXCELFILES/")
files = os.listdir(path)
files
print (files)
files = [f for f in files if f[-4:] == 'xlsx']
files
df=pd.DaataFrame()
for f in files:
data = pd.read_excel(f, 'Sheet1')
df = df.append(data)
writer=pd.ExcelWriter ("CosolidateFile.xlsx")
df.to_excel(writer,"Sheet1")
writer.save()
错误消息:
> Traceback (most recent call last): File
> "C:\Users\SHARAN\Desktop\ExcelMerge2.py", line 2, in <module>
> import pandas as pd File "C:\Python\lib\site-packages\pandas\__init__.py", line 55, in <module>
> from pandas.core.api import ( File "C:\Python\lib\site-packages\pandas\core\api.py", line 29, in <module>
> from pandas.core.groupby import Grouper, NamedAgg File "C:\Python\lib\site-packages\pandas\core\groupby\__init__.py", line 1,
> in <module>
> from pandas.core.groupby.generic import DataFrameGroupBy, NamedAgg, SeriesGroupBy File
> "C:\Python\lib\site-packages\pandas\core\groupby\generic.py", line 60,
> in <module>
> from pandas.core.frame import DataFrame File "C:\Python\lib\site-packages\pandas\core\frame.py", line 124, in
> <module>
> from pandas.core.series import Series File "C:\Python\lib\site-packages\pandas\core\series.py", line 4572, in
> <module>
> Series._add_series_or_dataframe_operations() File "C:\Python\lib\site-packages\pandas\core\generic.py", line 10349, in
> _add_series_or_dataframe_operations
> from pandas.core.window import EWM, Expanding, Rolling, Window File "C:\Python\lib\site-packages\pandas\core\window\__init__.py",
> line 1, in <module>
> from pandas.core.window.ewm import EWM # noqa:F401 File "C:\Python\lib\site-packages\pandas\core\window\ewm.py", line 5, in
> <module>
> **import pandas._libs.window.aggregations as window_aggregations ImportError: DLL load failed while importing aggregations: The
> specified module could not be found.**
答案 0 :(得分:0)
我有同样的错误。我只是卸载Python3.8并安装Anaconda Python(3.7)。我不完全是问题所在。但是我想3.8可能有一个依赖问题。如果使用Python3.8。您可以尝试这种方式。
答案 1 :(得分:0)
尝试使用旧版本
pip uninstall pandas
pip install pandas==0.25.3