Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DEPR: DataFrame.lookup #35224

Merged
merged 36 commits into from Sep 17, 2020
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
5bbddce
DEPR - 18262 - deprecate lookup
erfannariman Jul 11, 2020
02b50ac
DEPR - 18262 - changes black
erfannariman Jul 11, 2020
ca8bf05
Add test for deprecation lookup
erfannariman Jul 11, 2020
dea45b9
Added deprecation to whatsnew
erfannariman Jul 11, 2020
5f116ad
Add test for deprecation lookup
erfannariman Jul 11, 2020
0c04e90
FIX - 18262 - add warnings to other tests
erfannariman Jul 11, 2020
758468d
Merge remote-tracking branch 'upstream/master' into 18262-depr-lookup
erfannariman Jul 11, 2020
7ac3b32
DOC - 18262 - added example to lookup values
erfannariman Jul 11, 2020
2ab80cf
DOC - 18262 - point to example in depr
erfannariman Jul 11, 2020
94a6c0f
FIX - 18262 - deprecation warning before summary
erfannariman Jul 11, 2020
a339131
FIX - 18262 - whitespaces after comma
erfannariman Jul 11, 2020
269e4cc
FIX - 18262 - removed double line break
erfannariman Jul 11, 2020
0c40d69
Fix variable in ipython
erfannariman Jul 11, 2020
1ca23bc
18262 - removed linebreak
erfannariman Jul 12, 2020
9681a3d
18262 - Fix merge conflict
erfannariman Jul 15, 2020
6342ad2
18262 - replaced depr message
erfannariman Jul 15, 2020
3dfe19d
18262 - line break too long line
erfannariman Jul 15, 2020
187d47b
18262 - set header size
erfannariman Jul 15, 2020
db63df7
[FIX] - 18262 - Merge conflict
erfannariman Jul 28, 2020
227fad5
[FIX] - 18262 - removed extra dash header
erfannariman Jul 28, 2020
ce775ce
[FIX] - 18262 - reference to section in docs
erfannariman Jul 28, 2020
2ee7d09
[FIX] - 18262 - grammar / typos in docstring
erfannariman Jul 28, 2020
4c78311
Merge branch 'master' into 18262-depr-lookup
erfannariman Jul 28, 2020
f447185
Merge branch 'master' into 18262-depr-lookup
erfannariman Sep 13, 2020
dc2d367
moved depr version to 1.2
erfannariman Sep 13, 2020
293bd7a
test with linking to user guide
erfannariman Sep 13, 2020
cbca163
Remove line break
erfannariman Sep 13, 2020
90fa6a9
Merge branch 'master' into 18262-depr-lookup
erfannariman Sep 13, 2020
3eefd8e
Merge branch 'master' into 18262-depr-lookup
erfannariman Sep 14, 2020
4c3c163
Revert whatsnew v1.1.0
erfannariman Sep 14, 2020
b5a34e3
Added depr message in whatsnew v1.2.0
erfannariman Sep 14, 2020
ba4fb8a
replace query with loc
erfannariman Sep 14, 2020
6b91db6
add melt and loc to depr msg
erfannariman Sep 14, 2020
ff7724f
add dot
erfannariman Sep 14, 2020
104e3cb
added colon hyperlink
erfannariman Sep 15, 2020
25e78dd
updates
erfannariman Sep 16, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/source/whatsnew/v1.1.0.rst
Expand Up @@ -824,6 +824,7 @@ Deprecations
precision through the ``rtol``, and ``atol`` parameters, thus deprecating the
``check_less_precise`` parameter. (:issue:`13357`).
- :func:`DataFrame.melt` accepting a value_name that already exists is deprecated, and will be removed in a future version (:issue:`34731`)
- :meth:`DataFrame.lookup` is deprecated and will be removed in a future version, use :meth:`DataFrame.melt` and :meth:`DataFrame.loc` instead (:issue:`18682`)

.. ---------------------------------------------------------------------------

Expand Down
11 changes: 11 additions & 0 deletions pandas/core/frame.py
Expand Up @@ -3772,6 +3772,11 @@ def lookup(self, row_labels, col_labels) -> np.ndarray:
Given equal-length arrays of row and column labels, return an
array of the values corresponding to each (row, col) pair.

.. deprecated:: 1.1.0

DataFrame.lookup is deprecated,
use DataFrame.melt and DataFrame.loc instead.
erfannariman marked this conversation as resolved.
Show resolved Hide resolved

Parameters
----------
row_labels : sequence
Expand All @@ -3784,6 +3789,12 @@ def lookup(self, row_labels, col_labels) -> np.ndarray:
numpy.ndarray
The found values.
"""
msg = (
"The 'lookup' method is deprecated and will be"
erfannariman marked this conversation as resolved.
Show resolved Hide resolved
"removed in a future version."
)
warnings.warn(msg, FutureWarning, stacklevel=2)

n = len(row_labels)
if n != len(col_labels):
raise ValueError("Row labels must have same size as column labels")
Expand Down
9 changes: 9 additions & 0 deletions pandas/tests/frame/indexing/test_indexing.py
Expand Up @@ -2229,3 +2229,12 @@ def test_object_casting_indexing_wraps_datetimelike():
assert blk.dtype == "m8[ns]" # we got the right block
val = blk.iget((0, 0))
assert isinstance(val, pd.Timedelta)


def test_lookup_deprecated():
# GH18262
df = pd.DataFrame(
{"col": ["A", "A", "B", "B"], "A": [80, 23, np.nan, 22], "B": [80, 55, 76, 67]}
)
with tm.assert_produces_warning(FutureWarning):
df.lookup(df.index, df["col"])