Skip to content

Commit dbdd556

Browse files
topper-123vaibhavhrt
authored andcommitted
Remove NDFrame.select (pandas-dev#26641)
1 parent da6900e commit dbdd556

File tree

6 files changed

+1
-85
lines changed

6 files changed

+1
-85
lines changed

doc/source/reference/frame.rst

-1
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,6 @@ Reindexing / Selection / Label manipulation
204204
DataFrame.rename_axis
205205
DataFrame.reset_index
206206
DataFrame.sample
207-
DataFrame.select
208207
DataFrame.set_axis
209208
DataFrame.set_index
210209
DataFrame.tail

doc/source/reference/series.rst

-1
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,6 @@ Reindexing / Selection / Label manipulation
211211
Series.rename_axis
212212
Series.reset_index
213213
Series.sample
214-
Series.select
215214
Series.set_axis
216215
Series.take
217216
Series.tail

doc/source/whatsnew/v0.25.0.rst

+1
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,7 @@ Removal of prior version deprecations/changes
487487
- Removed the previously deprecated ``parse_cols`` keyword in :func:`read_excel` (:issue:`16488`)
488488
- Removed the previously deprecated ``pd.options.html.border`` (:issue:`16970`)
489489
- Removed the previously deprecated ``convert_objects`` (:issue:`11221`)
490+
- Removed the previously deprecated ``select`` method of ``DataFrame`` and ``Series`` (:issue:`17633`)
490491

491492
.. _whatsnew_0250.performance:
492493

pandas/core/generic.py

-34
Original file line numberDiff line numberDiff line change
@@ -3682,40 +3682,6 @@ class animal locomotion
36823682

36833683
_xs = xs # type: Callable
36843684

3685-
def select(self, crit, axis=0):
3686-
"""
3687-
Return data corresponding to axis labels matching criteria.
3688-
3689-
.. deprecated:: 0.21.0
3690-
Use df.loc[df.index.map(crit)] to select via labels
3691-
3692-
Parameters
3693-
----------
3694-
crit : function
3695-
To be called on each index (label). Should return True or False
3696-
axis : int
3697-
3698-
Returns
3699-
-------
3700-
selection : same type as caller
3701-
"""
3702-
warnings.warn("'select' is deprecated and will be removed in a "
3703-
"future release. You can use "
3704-
".loc[labels.map(crit)] as a replacement",
3705-
FutureWarning, stacklevel=2)
3706-
3707-
axis = self._get_axis_number(axis)
3708-
axis_name = self._get_axis_name(axis)
3709-
axis_values = self._get_axis(axis)
3710-
3711-
if len(axis_values) > 0:
3712-
new_axis = axis_values[
3713-
np.asarray([bool(crit(label)) for label in axis_values])]
3714-
else:
3715-
new_axis = axis_values
3716-
3717-
return self.reindex(**{axis_name: new_axis})
3718-
37193685
def reindex_like(self, other, method=None, copy=True, limit=None,
37203686
tolerance=None):
37213687
"""

pandas/tests/frame/test_axis_select_reindex.py

-35
Original file line numberDiff line numberDiff line change
@@ -895,41 +895,6 @@ def test_filter_corner(self):
895895
result = empty.filter(like='foo')
896896
assert_frame_equal(result, empty)
897897

898-
def test_select(self):
899-
900-
# deprecated: gh-12410
901-
f = lambda x: x.weekday() == 2
902-
index = self.tsframe.index[[f(x) for x in self.tsframe.index]]
903-
expected_weekdays = self.tsframe.reindex(index=index)
904-
905-
with tm.assert_produces_warning(FutureWarning,
906-
check_stacklevel=False):
907-
result = self.tsframe.select(f, axis=0)
908-
assert_frame_equal(result, expected_weekdays)
909-
910-
result = self.frame.select(lambda x: x in ('B', 'D'), axis=1)
911-
expected = self.frame.reindex(columns=['B', 'D'])
912-
assert_frame_equal(result, expected, check_names=False)
913-
914-
# replacement
915-
f = lambda x: x.weekday == 2
916-
result = self.tsframe.loc(axis=0)[f(self.tsframe.index)]
917-
assert_frame_equal(result, expected_weekdays)
918-
919-
crit = lambda x: x in ['B', 'D']
920-
result = self.frame.loc(axis=1)[(self.frame.columns.map(crit))]
921-
expected = self.frame.reindex(columns=['B', 'D'])
922-
assert_frame_equal(result, expected, check_names=False)
923-
924-
# doc example
925-
df = DataFrame({'A': [1, 2, 3]}, index=['foo', 'bar', 'baz'])
926-
927-
crit = lambda x: x in ['bar', 'baz']
928-
with tm.assert_produces_warning(FutureWarning):
929-
expected = df.select(crit)
930-
result = df.loc[df.index.map(crit)]
931-
assert_frame_equal(result, expected, check_names=False)
932-
933898
def test_take(self):
934899
# homogeneous
935900
order = [3, 1, 2, 0]

pandas/tests/series/indexing/test_indexing.py

-14
Original file line numberDiff line numberDiff line change
@@ -772,20 +772,6 @@ def test_setitem_slice_into_readonly_backing_data():
772772
"""
773773

774774

775-
def test_select(test_data):
776-
# deprecated: gh-12410
777-
with tm.assert_produces_warning(FutureWarning,
778-
check_stacklevel=False):
779-
n = len(test_data.ts)
780-
result = test_data.ts.select(lambda x: x >= test_data.ts.index[n // 2])
781-
expected = test_data.ts.reindex(test_data.ts.index[n // 2:])
782-
assert_series_equal(result, expected)
783-
784-
result = test_data.ts.select(lambda x: x.weekday() == 2)
785-
expected = test_data.ts[test_data.ts.index.weekday == 2]
786-
assert_series_equal(result, expected)
787-
788-
789775
def test_pop():
790776
# GH 6600
791777
df = DataFrame({'A': 0, 'B': np.arange(5, dtype='int64'), 'C': 0, })

0 commit comments

Comments
 (0)