-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Adding test_map_missing_mixed to test_apply.py in pandas test suite series #20574
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
Changes from 7 commits
e3ae4a1
02e48d5
c7402a6
6ba3f07
50f12d7
138d096
9a88dd2
60ef503
e927be4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -576,3 +576,13 @@ def f(x): | |
result = s.map(f) | ||
exp = pd.Series(['Asia/Tokyo'] * 25, name='XX') | ||
tm.assert_series_equal(result, exp) | ||
|
||
@pytest.mark.parametrize("vals,mapping,exp", [ | ||
(list('abc'), {np.nan: 'not NaN'}, ['not NaN']), | ||
(list('abc'), {'string': 'another string'}, ['another string']), | ||
(list(range(3)), {42: 'the answer'}, ['the answer'])]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same comment as above, use 1 instead of 42. Just for consistency make the value numeric as well instead of 'the answer' |
||
def test_map_missing_mixed(self, vals, mapping, exp): | ||
s = pd.Series(vals + [list(mapping.keys())[0]]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't use the mapping keys here. |
||
result = s.map(mapping) | ||
|
||
tm.assert_series_equal(result[-1:].reset_index(drop=True), pd.Series(exp)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Think through the exp values you are passing in. They should obviously match the shape of your input but replace with NA values where appropriate. For your first example, if you did I'm not sure what you are trying to do with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your mapping should contain one of the values in the series, so use 'a' instead of 'string'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Riiight
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tests did pass
Just not like they should have