Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
cfperez opened this issue Oct 21, 2015 · 4 comments
Closed

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

cfperez opened this issue Oct 21, 2015 · 4 comments
Labels
Bug Compat pandas objects compatability with Numpy or Python functions
Milestone

Comments

@cfperez
Copy link
Contributor

cfperez commented Oct 21, 2015

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

@jreback
Copy link
Contributor

jreback commented Oct 21, 2015

prob never implemented

it's pretty trivial to fix (and obviously not tested so need some)
see how .sort_values does it, right above

pull requests welcome!

@jreback jreback added Bug Compat pandas objects compatability with Numpy or Python functions labels Oct 21, 2015
@jreback jreback added this to the Next Major Release milestone Oct 21, 2015
@cfperez
Copy link
Contributor Author

cfperez commented Oct 22, 2015

I'm on it!

@jreback
Copy link
Contributor

jreback commented Oct 27, 2015

closed by #11422

@jreback jreback closed this as completed Oct 27, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Compat pandas objects compatability with Numpy or Python functions
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants