A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/pandas-dev/pandas/issues/16263 below:

DataFrame.reset_index deletes index, does not all for ints as level arg · Issue #16263 · pandas-dev/pandas · GitHub

Code Sample, a copy-pastable example if possible
import pandas as pd
import numpy as np
pd.__version__

u'0.20.1'

data = pd.DataFrame(np.random.randn(4,4), columns=['A', 'B', 'C', 'D']) 
data
A B C D 0 -0.134549 2.352525 0.481132 -1.919506 1 1.980074 0.720437 0.410702 -0.703470 2 -3.063166 -0.781255 0.270469 -0.539081 3 -1.125265 0.308374 -0.166085 -1.253959
data.set_index(['A'], inplace=True)
data
B C D A -0.134549 2.352525 0.481132 -1.919506 1.980074 0.720437 0.410702 -0.703470 -3.063166 -0.781255 0.270469 -0.539081 -1.125265 0.308374 -0.166085 -1.253959
data.reset_index(level=['A'], inplace=True)
data
B C D 0 2.352525 0.481132 -1.919506 1 0.720437 0.410702 -0.703470 2 -0.781255 0.270469 -0.539081 3 0.308374 -0.166085 -1.253959 Problem description

between v0.19.2 and v0.20.1, the behavior of DataFrame.reset_index changed.
With a single set index:

Expected Output

v0.19.2 results:

data.reset_index(level=['A'], inplace=True)
data
A B C D 0 0.100442 -0.620740 -2.018020 1.059871 1 -0.530272 0.402598 -1.453445 -0.729623 2 -1.040126 -0.536687 -1.136123 -0.748891 3 -0.269727 0.182250 0.847344 0.785692 Output of pd.show_versions()
import pandas as pd
import numpy as np
pd.show_versions()
INSTALLED VERSIONS
------------------
commit: None
python: 2.7.13.final.0
python-bits: 64
OS: Darwin
OS-release: 15.6.0
machine: x86_64
processor: i386
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: None.None

pandas: 0.19.2
nose: None
pip: 9.0.1
setuptools: 35.0.2
Cython: None
numpy: 1.12.1
scipy: None
statsmodels: None
xarray: None
IPython: 5.3.0
sphinx: None
patsy: None
dateutil: 2.6.0
pytz: 2017.2
blosc: None
bottleneck: None
tables: None
numexpr: None
matplotlib: None
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: 0.999999999
httplib2: None
apiclient: None
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: 2.9.6
boto: None
pandas_datareader: None

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4