Getting RuntimeError: dictionary changed size during iteration with `read_excel`
See original GitHub issueCode Sample, a copy-pastable example if possible
df = pd.read_excel(file)
66 def augment_keys(adict, uri):
67 # uri must already be enclosed in {}
---> 68 for x in adict.keys():
69 adict[uri + x] = adict[x]
70
RuntimeError: dictionary changed size during iteration
Problem description
I’ve been getting this issue when trying to read excel files into dataframes. My workaround for now is to export as a csv and read_csv()
which works fine. The read_excel
method used to work before and would be nice to have it working again to avoid this extra step.
I also get this same issue w/xlrd when I run the below code, so not certain if this is a pandas issue or xlrd issue:
import xlrd
book = xlrd.open_workbook(file)
[paste the output of pd.show_versions()
here below this line]
INSTALLED VERSIONS
commit: None python: 3.6.4.final.0 python-bits: 32 OS: Windows OS-release: 7 machine: AMD64 processor: Intel64 Family 6 Model 78 Stepping 3, GenuineIntel byteorder: little LC_ALL: None LANG: None LOCALE: None.None
pandas: 0.23.3 pytest: None pip: 10.0.1 setuptools: 38.5.1 Cython: None numpy: 1.14.0 scipy: None pyarrow: None xarray: None IPython: 6.2.1 sphinx: None patsy: None dateutil: 2.6.1 pytz: 2018.3 blosc: None bottleneck: None tables: None numexpr: None feather: None matplotlib: None openpyxl: None xlrd: 0.9.0 xlwt: None xlsxwriter: None lxml: None bs4: None html5lib: 1.0.1 sqlalchemy: None pymysql: None psycopg2: None jinja2: 2.10 s3fs: None fastparquet: None pandas_gbq: None pandas_datareader: None
Issue Analytics
- State:
- Created 5 years ago
- Comments:8 (5 by maintainers)
Top GitHub Comments
Your problem looks to have been addressed within xlrd:
https://github.com/python-excel/xlrd/issues/30
Should just need to upgrade from 0.9.0
yes,thanks