You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In [1]: importpandasaspd, StringIOIn [2]: csv=StringIO.StringIO('time,data\n0,10\n1,11\n2,12\n4,14\n5,15\n3,13')
In [3]: df=pd.read_csv(csv, index_col='time')
In [4]: dfOut[4]:
datatime010111212414515313In [5]: df.sort(inplace=True)
In [6]: dfOut[6]:
datatime010111212313414515
Specifying squeeze=True returns a view instead of first-class object? Is this by design and if so, why?
As of 0.14.1, inplace=True is the default (related #5190) for series sorts so the following error will occur by default if squeeze=True was specified.
In [1]: importpandasaspd, StringIOIn [2]: csv=StringIO.StringIO('time,data\n0,10\n1,11\n2,12\n4,14\n5,15\n3,13')
In [3]: df=pd.read_csv(csv, index_col='time', squeeze=True)
In [4]: dfOut[4]:
datatime010111212414515313In [5]: df.sort(inplace=True)
---------------------------------------------------------------------------ValueErrorTraceback (mostrecentcalllast)
<ipython-input-5-850f333de498>in<module>()
---->1df.sort(inplace=True)
C:\WinPython-64bit-2.7.5.3\python-2.7.5.amd64\lib\site-packages\pandas\core\series.pycinsort(self, axis, ascending, kind, na_position, inplace)
1651kind=kind,
1652na_position=na_position,
->1653inplace=inplace)
16541655deforder(self, na_last=None, ascending=True, kind='quicksort', na_position='last', inplace=False):
C:\WinPython-64bit-2.7.5.3\python-2.7.5.amd64\lib\site-packages\pandas\core\series.pycinorder(self, na_last, ascending, kind, na_position, inplace)
1684# GH 5856/58531685ifinplaceandself._is_cached:
->1686raiseValueError("This Series is a view of some other array, to "1687"sort in-place you must create a copy")
1688ValueError: ThisSeriesisaviewofsomeotherarray, tosortin-placeyoumustcreateacopy
The text was updated successfully, but these errors were encountered:
Specifying
squeeze=True
returns a view instead of first-class object? Is this by design and if so, why?As of 0.14.1,
inplace=True
is the default (related #5190) for series sorts so the following error will occur by default ifsqueeze=True
was specified.The text was updated successfully, but these errors were encountered: