Skip to content

Commit de6318e

Browse files
committed
ENH, closes #773 PR, deprecating column for columns
1 parent de486d6 commit de6318e

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

pandas/core/frame.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2159,7 +2159,7 @@ def duplicated(self, cols=None, take_last=False):
21592159
#----------------------------------------------------------------------
21602160
# Sorting
21612161

2162-
def sort(self, columns=None, axis=0, ascending=True):
2162+
def sort(self, columns=None, column=None, axis=0, ascending=True):
21632163
"""
21642164
Sort DataFrame either by labels (along either axis) or by the values in
21652165
column(s)
@@ -2178,6 +2178,10 @@ def sort(self, columns=None, axis=0, ascending=True):
21782178
-------
21792179
sorted : DataFrame
21802180
"""
2181+
if column is not None:
2182+
import warnings
2183+
warnings.warn("column is deprecated, use columns", FutureWarning)
2184+
columns = column
21812185
return self.sort_index(by=columns, axis=axis, ascending=ascending)
21822186

21832187
def sort_index(self, axis=0, by=None, ascending=True):

pandas/tests/test_frame.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3553,14 +3553,18 @@ def test_sort_index(self):
35533553
assert_frame_equal(sorted_df, expected)
35543554

35553555
# check for now
3556-
sorted_df = frame.sort(column='A')
3556+
sorted_df = frame.sort(columns='A')
35573557
expected = frame.sort_index(by='A')
35583558
assert_frame_equal(sorted_df, expected)
35593559

3560-
sorted_df = frame.sort(column='A', ascending=False)
3560+
sorted_df = frame.sort(columns='A', ascending=False)
35613561
expected = frame.sort_index(by='A', ascending=False)
35623562
assert_frame_equal(sorted_df, expected)
35633563

3564+
sorted_df = frame.sort(columns=['A', 'B'], ascending=False)
3565+
expected = frame.sort_index(by=['A', 'B'], ascending=False)
3566+
assert_frame_equal(sorted_df, expected)
3567+
35643568
def test_sort_index_multicolumn(self):
35653569
import random
35663570
A = np.arange(5).repeat(20)

0 commit comments

Comments
 (0)