Closed
Description
Code Sample, a copy-pastable example if possible
import pandas as pd
df = pd.DataFrame({'x': [1., 5., 3.]}, index=[0, 2, 4])
df.index.name = 'frame'
df.reset_index('frame')
Problem description
Resetting the index on pandas 0.20.1 and python 2.7 results in the following exception:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Anaconda3\envs\tpissue\lib\site-packages\pandas\core\frame.py", line 3055, in reset_index
if level is None or i in level:
TypeError: 'in <string>' requires string as left operand, not int
In the example, it doesn't matter if you use Unicode or non-unicode strings. (using from __future__ import unicode_literals
). Ref soft-matter/trackpy#446 @manuescobedo
Expected Output
A reindexed DataFrame.
Output of pd.show_versions()
INSTALLED VERSIONS
------------------
commit: None
python: 2.7.13.final.0
python-bits: 64
OS: Windows
OS-release: 7
machine: AMD64
processor: Intel64 Family 6 Model 58 Stepping 9, GenuineIntel
byteorder: little
LC_ALL: None
LANG: None
LOCALE: None.None
pandas: 0.20.1
pytest: None
pip: 9.0.1
setuptools: 27.2.0
Cython: None
numpy: 1.12.1
scipy: 0.19.1
xarray: None
IPython: None
sphinx: None
patsy: None
dateutil: 2.6.0
pytz: 2017.2
blosc: None
bottleneck: None
tables: 3.4.2
numexpr: 2.6.2
feather: None
matplotlib: 2.0.2
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: None
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: 2.9.5
s3fs: None
pandas_gbq: None
pandas_datareader: None