【发布时间】:2023-04-10 16:28:03
【问题描述】:
我正在尝试阅读完整的泰坦尼克号数据集,可在此处找到:
biostat.mc.vanderbilt.edu/wiki/pub/Main/DataSets/titanic3.xls
Kaggle 将数据保存为两个 csv 文件(可以正常加载),但是他们故意省略了测试集的生存数据。
有问题的文件是 titanic3.xls,包含在上述引用页面底部的 tarball 文件中。
这是我的代码:
import pandas as pd
ship = pd.read_excel('titanic3.xls')
以及输出错误:
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-2-be0879be6ad0> in <module>()
----> 1 ship = pd.read_excel('titanic3.xls')
/usr/local/lib/python3.6/site-packages/pandas/io/excel.py in read_excel(io, sheetname, header, skiprows, skip_footer, index_col, names, parse_cols, parse_dates, date_parser, na_values, thousands, convert_float, has_index_names, converters, dtype, true_values, false_values, engine, squeeze, **kwds)
198
199 if not isinstance(io, ExcelFile):
--> 200 io = ExcelFile(io, engine=engine)
201
202 return io._parse_excel(
/usr/local/lib/python3.6/site-packages/pandas/io/excel.py in __init__(self, io, **kwds)
227 def __init__(self, io, **kwds):
228
--> 229 import xlrd # throw an ImportError if we need to
230
231 ver = tuple(map(int, xlrd.__VERSION__.split(".")[:2]))
ModuleNotFoundError: No module named 'xlrd'
我正在使用 Python 2.7
【问题讨论】:
-
兄弟,tarball中没有excel文件
-
可能把我的链接搞混了。将链接更新为直接下载。
标签: python excel python-2.7 pandas data-science