Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
91dc84f
BUG/TST: Fix failing FRED comparison tests.
Sep 20, 2013
7b55b92
DOC: v0.13.0.txt typos
jreback Sep 16, 2013
3652a5e
CLN: _axis_len checking cleanup and better message
jreback Sep 16, 2013
41ee54c
COMPAT: unicode compat issue fix
jreback Sep 16, 2013
4104c03
TST: reproducing tests for subtle PyTables bug (disabled for now), see:
jreback Sep 17, 2013
cc302e2
DOC: show a more informative query performance plot
cpcloud Sep 17, 2013
b903689
DOC: added bitwise op disallow clarification in eval docs
cpcloud Sep 17, 2013
e692104
ENH: Better read_json error when handling bad keys
jtratner Sep 14, 2013
df9e633
BUG: fix sort_index with one col and ascending list
jtratner Sep 15, 2013
48beb8e
DOC: v0.13.0 HDFStore corrections
jreback Sep 17, 2013
4c0fbca
BLD: fix json to build on windows, @Komnomnomnom
jreback Sep 17, 2013
2df7f83
TST: dtypes tests fix for 32-bit
jreback Sep 17, 2013
8f0b4f5
BLD: json mingw doesnt have sprintf_s
Komnomnomnom Sep 15, 2013
f3a5391
TST: windows dtype 32-bit fixes
Komnomnomnom Sep 18, 2013
7ebd3b1
FIX: iso date encoding year overflow
Komnomnomnom Sep 18, 2013
4a8f20e
ENH: Add makePeriodPanel
dalejung Sep 17, 2013
f1fb8f0
BUG: (GH4853) Fixed Panel.shift/tshift to use freq.
dalejung Sep 17, 2013
4af9288
DOC: v0.13.0 adds
jreback Sep 18, 2013
f33dfbb
CLN: clean up test_graphics.py
cpcloud Sep 18, 2013
749669f
CLN: clean up tseries/tests/test_plotting.py
cpcloud Sep 18, 2013
a67fa5b
BUG: Fix for issue with PythonParser::_check_thousands. (GH4596)
cancan101 Aug 18, 2013
c051c35
BUG: bug in getitem with a duplicate index when using where (GH4879)
jreback Sep 19, 2013
ed1683f
CLN: move README.rst to markdown
cpcloud Sep 19, 2013
5f05f00
BUG: off-by-one when doing network test repeats
esc Aug 6, 2013
edbf949
BUG/TST: fix (and skip) tests that have been failing unnoticed all along
esc Aug 6, 2013
fda172d
BUG/TST: Fix failing FRED comparison tests.
Sep 20, 2013
0d68313
Merge branch 'fixfred2' of https://github.com/TomAugspurger/pandas in…
Sep 20, 2013
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
BUG: fix sort_index with one col and ascending list
now actually checks the first element of the list
  • Loading branch information
jtratner authored and TomAugspurger committed Sep 20, 2013
commit df9e633a0ad96ce256a9ab11ca647bf9e196decd
4 changes: 4 additions & 0 deletions doc/source/release.rst
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,10 @@ Bug Fixes
across different versions of matplotlib (:issue:`4789`)
- Suppressed DeprecationWarning associated with internal calls issued by repr() (:issue:`4391`)
- Fixed an issue with a duplicate index and duplicate selector with ``.loc`` (:issue:`4825`)
- Fixed an issue with ``DataFrame.sort_index`` where, when sorting by a
single column and passing a list for ``ascending``, the argument for
``ascending`` was being interpreted as ``True`` (:issue:`4839`,
:issue:`4846`)

pandas 0.12.0
-------------
Expand Down
7 changes: 6 additions & 1 deletion pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -2856,7 +2856,7 @@ def sort_index(self, axis=0, by=None, ascending=True, inplace=False,

Examples
--------
>>> result = df.sort_index(by=['A', 'B'], ascending=[1, 0])
>>> result = df.sort_index(by=['A', 'B'], ascending=[True, False])

Returns
-------
Expand All @@ -2875,6 +2875,9 @@ def sort_index(self, axis=0, by=None, ascending=True, inplace=False,
raise ValueError('When sorting by column, axis must be 0 (rows)')
if not isinstance(by, (tuple, list)):
by = [by]
if com._is_sequence(ascending) and len(by) != len(ascending):
raise ValueError('Length of ascending (%d) != length of by'
' (%d)' % (len(ascending), len(by)))

if len(by) > 1:
keys = []
Expand All @@ -2900,6 +2903,8 @@ def trans(v):
raise ValueError('Cannot sort by duplicate column %s'
% str(by))
indexer = k.argsort(kind=kind)
if isinstance(ascending, (tuple, list)):
ascending = ascending[0]
if not ascending:
indexer = indexer[::-1]
elif isinstance(labels, MultiIndex):
Expand Down
19 changes: 16 additions & 3 deletions pandas/tests/test_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -8796,24 +8796,37 @@ def test_sort_index(self):
expected = frame.ix[frame.index[indexer]]
assert_frame_equal(sorted_df, expected)

sorted_df = frame.sort(columns='A', ascending=False)
assert_frame_equal(sorted_df, expected)

# GH4839
sorted_df = frame.sort(columns=['A'], ascending=[False])
assert_frame_equal(sorted_df, expected)

# check for now
sorted_df = frame.sort(columns='A')
assert_frame_equal(sorted_df, expected[::-1])
expected = frame.sort_index(by='A')
assert_frame_equal(sorted_df, expected)

sorted_df = frame.sort(columns='A', ascending=False)
expected = frame.sort_index(by='A', ascending=False)
assert_frame_equal(sorted_df, expected)

sorted_df = frame.sort(columns=['A', 'B'], ascending=False)
expected = frame.sort_index(by=['A', 'B'], ascending=False)
assert_frame_equal(sorted_df, expected)

sorted_df = frame.sort(columns=['A', 'B'])
assert_frame_equal(sorted_df, expected[::-1])

self.assertRaises(ValueError, frame.sort_index, axis=2, inplace=True)

msg = 'When sorting by column, axis must be 0'
with assertRaisesRegexp(ValueError, msg):
frame.sort_index(by='A', axis=1)

msg = r'Length of ascending \(5\) != length of by \(2\)'
with assertRaisesRegexp(ValueError, msg):
frame.sort_index(by=['A', 'B'], axis=0, ascending=[True] * 5)

def test_sort_index_multicolumn(self):
import random
A = np.arange(5).repeat(20)
Expand Down