-
-
Notifications
You must be signed in to change notification settings - Fork 18k
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
BUG: Series.combine() fails with ExtensionArray inside of Series #21183
Changes from 2 commits
7469ca9
bbb6640
339b23a
61a09e7
d862e83
4c925fc
27480ac
f96372e
677fe18
9fceee7
1010cb5
aceea9f
79506ac
0e4720b
2a21117
e08f832
d3ed2c7
4ca28b2
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 |
---|---|---|
|
@@ -2,9 +2,6 @@ | |
|
||
import pytest | ||
import numpy as np | ||
import pandas as pd | ||
|
||
import pandas.util.testing as tm | ||
|
||
from pandas.api.types import CategoricalDtype | ||
from pandas import Categorical | ||
|
@@ -32,6 +29,15 @@ def data_missing(): | |
return Categorical([np.nan, 'A']) | ||
|
||
|
||
@pytest.fixture | ||
def data_repeated(): | ||
"""Return different versions of data for count times""" | ||
def gen(count): | ||
for _ in range(count): | ||
yield Categorical(make_data()) | ||
yield gen | ||
|
||
|
||
@pytest.fixture | ||
def data_for_sorting(): | ||
return Categorical(['A', 'B', 'C'], categories=['C', 'A', 'B'], | ||
|
@@ -157,16 +163,9 @@ class TestMethods(base.BaseMethodsTests): | |
def test_value_counts(self, all_data, dropna): | ||
pass | ||
|
||
def test_combine(self): | ||
# GH 20825 | ||
orig_data1 = make_data() | ||
orig_data2 = make_data() | ||
s1 = pd.Series(Categorical(orig_data1, ordered=True)) | ||
s2 = pd.Series(Categorical(orig_data2, ordered=True)) | ||
result = s1.combine(s2, lambda x1, x2: x1 <= x2) | ||
expected = pd.Series([a <= b for (a, b) in | ||
zip(orig_data1, orig_data2)]) | ||
tm.assert_series_equal(result, expected) | ||
@pytest.mark.skip(reason="combine add for categorical not supported") | ||
def test_combine_add(self, data_repeated): | ||
pass | ||
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. does it raise? if so pls tests that 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. This is interesting. Since
In pandas 0.23.0, this fails. But the binary operation is defined on an element by element basis, so the new implementation will return:
IMHO, this is correct, because of what |
||
|
||
|
||
class TestCasting(base.BaseCastingTests): | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,6 +30,15 @@ def all_data(request, data, data_missing): | |
return data_missing | ||
|
||
|
||
@pytest.fixture | ||
def data_repeated(): | ||
"""Return different versions of data for count times""" | ||
def gen(count): | ||
for _ in range(count): | ||
yield NotImplemented | ||
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. NotImplemented -> NotImplementedError 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. Fixed |
||
yield gen | ||
|
||
|
||
@pytest.fixture | ||
def data_for_sorting(): | ||
"""Length-3 array with a known sort order. | ||
|
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.
can you give a 1-liner explaining what this is testing. the name of the test is uninformative.
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.
done