我是Python新手,有个问题。我试图导入一个excel文件与熊猫,我使用VS代码。
import pandas as pd
data = pd.read_excel(r'D:\Python\user.xlsx')
print(data)
我已经安装了xlrd,但是我得到了这个错误:
Traceback (most recent call last):
File "d:\Python\import-excel.py", line 24, in <module>
data = pd.read_excel(r'D:\Python\u
嗯,我最近买了一台新电脑,安装了Spyder和Python,并使用pip更新了库。除了当我尝试导入excel文件时Pandas之外,一切都运行得很好。 这是我的代码 import pandas as pd
filename = "sample_sheet.xlsx"
data = pd.read_excel(filename) 这是我得到的错误 ImportError: Missing optional dependency 'xlrd'. Install xlrd >= 1.0.0 for Excel support Use pip or c
这是读取excel中数据的代码。
import os
import pandas as pd #pandas library is to work with dataframes
os.chdir("C:\Education\Study Materials\Python for Data science\Data Sets")
data_xlsx=pd.read_excel("Iris_data_sample.xlsx", sheet_name="Iris_data")
错误: ImportError:缺少可选的依赖项'xlrd‘。安装
下面是我的setup.py代码:
from os import path
import sys
python_version = sys.version_info[:2]
if python_version < (2, 6):
raise Exception("This version of xlrd requires Python 2.6 or above. "
"For older versions of Python, you can use the 0.8 series.")
av = sys.argv
我试图查找一个.xlsx文件是否包含一个@。我使用过熊猫,它们工作得很好,除非excel表中的第一列为空,那么它就失败了。有什么想法吗?如何重写代码来处理/跳过空列?
守则:
df = pandas.read_excel(open(path,'rb'), sheetname=0)
out = 'False'
for col in df.columns:
if df[col].str.contains('@').any():
out = 'True'
break
这是我正在犯的错误:
我有一个脚本,它读取一个xlsx文件,该文件直到一周前才正常工作。错误信息是:
xlrd.biffh.XLRDError:无法在OLE2复合文档中找到工作簿
通过调试脚本,我找到了整个堆栈:
C:\MyFolder\MyScript.py", line 42, in PandasReadExcel
ef=pd.read_excel(excfile,sheetname,header,skiprows)
File "C:\Python\Python36\lib\site-packages\pandas\io\excel.py", line 191, in read
我使用的是Juypter,我从包含笔记本和Excel文件的同一目录中启动它。我使用以下命令:
import pandas as pd
!ls # Returns the contents of the working directory. Use "dir" in a Windows.
它返回:
Book1.xlsx
common\_excel\_tasks.ipynb
然后,我使用以下命令:
excel_file = 'Book1.xlsx'
df1 = pd.read_excel(excel_file)
但我得到以下错误:
-----------
我尝试了中的代码
代码
# Import the xlrd module
import xlrd
# Define the location of the file
loc = ("C:\\Users\User\\Desktop\\Book1.xlsx")
# To open the Workbook
wb = xlrd.open_workbook(loc)
sheet = wb.sheet_by_index(0)
# For row 0 and column 0
sheet.cell_value(0, 0)
我的E
我正在尝试将一个excel文件导入到Pandas中。我正在使用df=pd.read_excel(file_path),但它一直给我带来这个错误:
*** No CODEPAGE record, no encoding_override: will use 'ascii'
*** No CODEPAGE record, no encoding_override: will use 'ascii'
Traceback (most recent call last):
File "/Users/santanna_santanna/PycharmProjec
我的问题在下面,但任何有xlrd经验的人都会有兴趣的评论。
我刚刚找到了xlrd,它看起来是一个完美的解决方案,但我在入门时遇到了一些问题。我正在尝试从我从道琼斯工业股票平均价格指数( Dow Jones Industrial Average )当前成分股(链接:)中提取的Excel文件中以编程方式提取数据。
当我打开未修改的文件时,我得到一个讨厌的BIFF错误(无法识别二进制格式)
然而,你可以在这张截图中看到,Excel2008 for Mac认为它是‘Excel1997-2004’格式(截图:)
如果我手动在Excel中打开它,并显式地另存为'Excel 1997-2004‘格式
我正在尝试在我的苹果电脑上安装xlrd包,以便在Python3.5.4中使用,以便能够阅读excel文档。
我已经打开了'Terminal‘并输入:
pip install xlrd
但是我一直收到这个错误:
Downloading/unpacking xlrd
Cannot fetch index base URL https://pypi.python.org/simple/
Could not find any downloads that satisfy the requirement xlrd
Cleaning up...
No distributions at a
我有一个来自pandas文档站点的示例,但无法运行它。导出为excel文件效果良好,但以下导入效果不佳:
import numpy as np
import pandas as pd
df = pd.DataFrame(np.random.randn(1000, 4), columns=list("ABCD"))
df = df.cumsum()
df.to_excel("/tmp/foo.xlsx", sheet_name="Sheet1")
print("Reading data back from an exce
我有一个包含许多工作表的excel文件。每张工作表中只有一列,即A列。我打算用read_excel()方法读取excel文件。代码如下:
import pandas as PD
ExcelFile = "C:\\AAA.xlsx"
SheetNames = ['0', '1', 'S', 'B', 'U']
# There are five sheets in this excel file. Those are the sheet names.
PageTotal = len(Sheet
我正在尝试编写一个脚本,它将打开/查看文件夹中的每个excel工作簿,从每个工作簿中提取特定的值,然后将这些值粘贴到新的csv中。
我的脚本(见下文)和所有49个工作簿都位于以下路径中: C:\Users\user.name\Desktop\Excel测试。
import pandas
import os
info_headers = ['Production Name', 'Data size (GBs)', 'Billable Data size (GBs)']
info = []
files = [file for file in os
昨天我遇到了这个错误,我已经通过安装缺少的可选依赖项来解决这个错误。但是今天,当我在PyCharm中启动另一个Python文件时,我又收到了同样的错误。
ImportError: Missing optional dependency 'xlrd'. Install xlrd >= 1.0.0 for Excel support Use pip or conda to install xlrd.
有人知道为什么会发生这种事吗?
我现在再试着安装它,pip确认它已经安装了。
C:\Users\Ben>pip install xlrd
Defaulting to use
我在excel工作簿中有一个带有逗号分隔值的单元格。
此单元格可以具有以下模式的值。
0或123或123, 345。
我希望使用XLRD或pandas.read_excel将它们提取为整数列表。
我尝试过使用xlrd和下面的代码片段。
book = open_workbook(args.path)
dep_cms = book.sheet_by_index(1)
for row_index in range(1, dep_cms.nrows)
excelList = []
excelList.extend([x.strip() for x in dep_cms.cell(