前提・実現したいこと
pythonの学習中にエクセルの読み込みを行おうとしたところ
以下のエラーが発生しました。
発生している問題・エラーメッセージ
--------------------------------------------------------------------------- AttributeError Traceback (most recent call last) <ipython-input-38-75af81949255> in <module> ----> 1 pd.read_excel('data01.xlsx') ~\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas\util\_decorators.py in wrapper(*args, **kwargs) 294 ) 295 warnings.warn(msg, FutureWarning, stacklevel=stacklevel) --> 296 return func(*args, **kwargs) 297 298 return wrapper ~\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas\io\excel\_base.py in read_excel(io, sheet_name, header, names, index_col, usecols, squeeze, dtype, engine, converters, true_values, false_values, skiprows, nrows, na_values, keep_default_na, na_filter, verbose, parse_dates, date_parser, thousands, comment, skipfooter, convert_float, mangle_dupe_cols) 302 303 if not isinstance(io, ExcelFile): --> 304 io = ExcelFile(io, engine=engine) 305 elif engine and engine != io.engine: 306 raise ValueError( ~\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas\io\excel\_base.py in __init__(self, path_or_buffer, engine) 865 self._io = stringify_path(path_or_buffer) 866 --> 867 self._reader = self._engines[engine](self._io) 868 869 def __fspath__(self): ~\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas\io\excel\_xlrd.py in __init__(self, filepath_or_buffer) 20 err_msg = "Install xlrd >= 1.0.0 for Excel support" 21 import_optional_dependency("xlrd", extra=err_msg) ---> 22 super().__init__(filepath_or_buffer) 23 24 @property ~\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas\io\excel\_base.py in __init__(self, filepath_or_buffer) 351 self.book = self.load_workbook(filepath_or_buffer) 352 elif isinstance(filepath_or_buffer, str): --> 353 self.book = self.load_workbook(filepath_or_buffer) 354 elif isinstance(filepath_or_buffer, bytes): 355 self.book = self.load_workbook(BytesIO(filepath_or_buffer)) ~\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas\io\excel\_xlrd.py in load_workbook(self, filepath_or_buffer) 35 return open_workbook(file_contents=data) 36 else: ---> 37 return open_workbook(filepath_or_buffer) 38 39 @property ~\AppData\Local\Programs\Python\Python39\lib\site-packages\xlrd\__init__.py in open_workbook(filename, logfile, verbosity, use_mmap, file_contents, encoding_override, formatting_info, on_demand, ragged_rows) 128 if 'xl/workbook.xml' in component_names: 129 from . import xlsx --> 130 bk = xlsx.open_workbook_2007_xml( 131 zf, 132 component_names, ~\AppData\Local\Programs\Python\Python39\lib\site-packages\xlrd\xlsx.py in open_workbook_2007_xml(zf, component_names, logfile, verbosity, use_mmap, formatting_info, on_demand, ragged_rows) 810 del zflo 811 zflo = zf.open(component_names['xl/workbook.xml']) --> 812 x12book.process_stream(zflo, 'Workbook') 813 del zflo 814 props_name = 'docprops/core.xml' ~\AppData\Local\Programs\Python\Python39\lib\site-packages\xlrd\xlsx.py in process_stream(self, stream, heading) 264 self.tree = ET.parse(stream) 265 getmethod = self.tag2meth.get --> 266 for elem in self.tree.iter() if Element_has_iter else self.tree.getiterator(): 267 if self.verbosity >= 3: 268 self.dump_elem(elem) AttributeError: 'ElementTree' object has no attribute 'getiterator'
該当のソースコード
python
1pd.read_excel('data01.xlsx')
試したこと
何を修正したらよいのかわからずに困っております。
補足情報(FW/ツールのバージョンなど)
ここにより詳細な情報を記載してください。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2020/12/02 07:15