Skip to content

Series.sort_index(inplace=True) always returns a new Series #11402

Closed
@cfperez

Description

@cfperez

Series.index_sort() always returns a new Series, ignoring the inplace keyword argument. This is in contrast to DataFrame's sort_index() which works as expected.

vals = range(10, 0, -1)
x = pd.Series(vals)

# Returns a new Series with the sorted index instead of
# changing x in place
y = x.sort_index(ascending=False, inplace=True)

# Not the same
(x != y).all()

# sort_index() works as expected for DataFrames
xx = pd.DataFrame({'col': x})
assert xx.sort_index(ascending=False, inplace=True) is None

show_versions() output:

INSTALLED VERSIONS

commit: None
python: 3.4.3.final.0
python-bits: 64
OS: Darwin
OS-release: 14.5.0
machine: x86_64
processor: i386
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8

pandas: 0.17.0
nose: 1.3.7
pip: 7.1.2
setuptools: 18.4
Cython: None
numpy: 1.10.1
scipy: 0.16.0
statsmodels: 0.6.1
IPython: 4.0.0
sphinx: None
patsy: 0.4.0
dateutil: 2.4.1
pytz: 2015.6
blosc: None
bottleneck: None
tables: 3.2.2
numexpr: 2.4.4
matplotlib: 1.4.3
openpyxl: 2.2.0-b1
xlrd: 0.9.3
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: None
httplib2: None
apiclient: None
sqlalchemy: 1.0.3
pymysql: 0.6.6.None
psycopg2: None

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugCompatpandas objects compatability with Numpy or Python functions

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions