Skip to content
Merged
Changes from all commits
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
12 changes: 12 additions & 0 deletions pandas/tests/series/test_apply.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,18 @@ 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 bug fixed in: GH 24275
s = pd.Series(series, dtype='category')
result = s.apply(lambda x: x.split('-')[0])
result = result.astype(object)
expected = pd.Series(['1', '1', np.NaN], dtype='category')
expected = expected.astype(object)
tm.assert_series_equal(result, expected)


class TestSeriesAggregate():

Expand Down