forked from pandas-dev/pandas
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TST: series/indexing tests parametrization + moving test methods (pan…
- Loading branch information
1 parent
7c14e4f
commit ed96567
Showing
8 changed files
with
378 additions
and
416 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import pandas as pd | ||
import pandas.util.testing as tm | ||
|
||
|
||
def test_getitem_callable(): | ||
# GH 12533 | ||
s = pd.Series(4, index=list('ABCD')) | ||
result = s[lambda x: 'A'] | ||
assert result == s.loc['A'] | ||
|
||
result = s[lambda x: ['A', 'B']] | ||
tm.assert_series_equal(result, s.loc[['A', 'B']]) | ||
|
||
result = s[lambda x: [True, False, True, True]] | ||
tm.assert_series_equal(result, s.iloc[[0, 2, 3]]) | ||
|
||
|
||
def test_setitem_callable(): | ||
# GH 12533 | ||
s = pd.Series([1, 2, 3, 4], index=list('ABCD')) | ||
s[lambda x: 'A'] = -1 | ||
tm.assert_series_equal(s, pd.Series([-1, 2, 3, 4], index=list('ABCD'))) | ||
|
||
|
||
def test_setitem_other_callable(): | ||
# GH 13299 | ||
inc = lambda x: x + 1 | ||
|
||
s = pd.Series([1, 2, -1, 4]) | ||
s[s < 0] = inc | ||
|
||
expected = pd.Series([1, 2, inc, 4]) | ||
tm.assert_series_equal(s, expected) |
Oops, something went wrong.