Skip to content

TST: tests for categorical apply #25095

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

Merged
merged 2 commits into from
Feb 3, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions pandas/tests/series/test_apply.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,17 @@ def test_apply_dict_depr(self):
with tm.assert_produces_warning(FutureWarning):
tsdf.A.agg({'foo': ['sum', 'mean']})

@pytest.mark.parametrize('series', [
['1-1', '1-1', np.NaN],
['1-1', '1-2', np.NaN]])
def test_apply_categorical_with_nan_values(self, series):
# GH 20714
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add 24275 here as well (the issue that fixed this)

s = pd.Series(series, dtype='category')
result = s.apply(lambda x: x.split('-')[0])
expected = pd.Series(['1', '1', np.NaN], dtype='category')
tm.assert_series_equal(result.astype(object),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't perform operations here, so them on the result / expected as appropriate, e.g.

result = 
result = result.astype(object)

is more appropriate

expected.astype(object), check_dtype=False)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are you not comparing dtype?



class TestSeriesAggregate():

Expand Down