-
Notifications
You must be signed in to change notification settings - Fork 50
fix: unordered mode too many labels issue. #1148
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
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 |
---|---|---|
|
@@ -2768,20 +2768,25 @@ def test_series_case_when(scalars_dfs_maybe_ordered): | |
|
||
# TODO(tswast): pandas case_when appears to assume True when a value is | ||
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. I would keep this comment, or rather add a dedicated test that clearly conveys the intent - 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. Updated to have all cases in the original test. Keep only one test can be overall faster I think. |
||
# null. I suspect this should be considered a bug in pandas. | ||
bf_result = bf_series.case_when( | ||
[ | ||
((bf_series > 100).fillna(True), bf_series - 1), | ||
((bf_series > 0).fillna(True), pd.NA), | ||
((bf_series < -100).fillna(True), -1000), | ||
] | ||
).to_pandas() | ||
pd_result = pd_series.case_when( | ||
[ | ||
(pd_series > 100, pd_series - 1), | ||
(pd_series > 0, pd.NA), | ||
(pd_series < -100, -1000), | ||
] | ||
|
||
# Generate 150 conditions to test case_when with a large number of conditions | ||
bf_conditions = ( | ||
[((bf_series > 645).fillna(True), bf_series - 1)] | ||
+ [((bf_series > (-100 + i * 5)).fillna(True), i) for i in range(148, 0, -1)] | ||
+ [((bf_series <= -100).fillna(True), pd.NA)] | ||
) | ||
|
||
pd_conditions = ( | ||
[((pd_series > 645), pd_series - 1)] | ||
+ [((pd_series > (-100 + i * 5)), i) for i in range(148, 0, -1)] | ||
+ [(pd_series <= -100, pd.NA)] | ||
) | ||
|
||
assert len(bf_conditions) == 150 | ||
|
||
bf_result = bf_series.case_when(bf_conditions).to_pandas() | ||
pd_result = pd_series.case_when(pd_conditions) | ||
|
||
pd.testing.assert_series_equal( | ||
bf_result, | ||
pd_result.astype(pd.Int64Dtype()), | ||
|
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.
Highly recommend adding a test using the customer's use case
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.
Added