python excel pandas openpyxl_Python错误集锦:在pandas中用to_excel()写xlsx文件提示:ModuleNotFoundError: No module ...

错误提示:

在pandas中用to_excel()写xlsx文件时提示:ModuleNotFoundError: No module named ‘openpyxl’:

import numpy as np

import pandas as pd

arr = np.random.randint(-50,50,size=(3,10))

ind = [x for x in range(3)]

columns = list('ABCDEFGHIJ')

df = pd.DataFrame(arr,index=ind,columns=columns)

print('df=\n',df)

df.to_excel('pd-test-w.xlsx') #这里是xlsx文件,不行xls文件

print('df=\n',df)

---------------------------------------------------------------------------

ModuleNotFoundError Traceback (most recent call last)

in

6 df = pd.DataFrame(arr,index=ind,columns=columns)

7 print('df=\n',df)

----> 8 df.to_excel('pd-test-w.xlsx')

d:\python\python38\lib\site-packages\pandas\core\generic.py in to_excel(self,

你可能感兴趣的:(python,excel,pandas,openpyxl)