Hello,
I noticed
df_ohlc['high'].sort(ascending=False)
raises
ValueError: This Series is a view of some other array, to sort in-place you must create a copy
which seems to mean that, by default, sort uses by default inplace=True
but according to
http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.sort.html
inplace : boolean, default False
Here is a minimal example:
import pandas as pd
import numpy as np
N = 1000
rng = pd.date_range('1/1/2011', periods=N, freq='H')
s = pd.Series(np.random.random(N), index=rng)
df_ohlc = s.resample('1D', how='ohlc')
df_ohlc['high'].sort(ascending=False)
raises ValueError: This Series is a view of some other array, to sort in-place you must create a copy
df_ohlc['high'].sort(ascending=False, inplace=True)
raises same exception
but
df_ohlc['high'].sort(ascending=False, inplace=False)
doesn't raises exception
Kind regards
Comment From: jreback
you are sorting a Series, not a frame .sort defaults to True for a Series
Comment From: s-celles
Thanks http://pandas.pydata.org/pandas-docs/stable/generated/pandas.Series.sort.html
it's odd to have by default inplace=True
for Series
and inplace=False
for DataFrame
Now I will remember.
Sorry
Comment From: jorisvandenbossche
It's indeed odd, and there are already a lot of discussions to have this solved (see eg #8239 and #9816), but we can't just change it for backward compatible reasons.