-
Notifications
You must be signed in to change notification settings - Fork 43
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
fix: unordered mode too many labels issue. #1148
Changes from 2 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 |
---|---|---|
|
@@ -2766,22 +2766,17 @@ def test_series_case_when(scalars_dfs_maybe_ordered): | |
bf_series = scalars_df["int64_col"] | ||
pd_series = scalars_pandas_df["int64_col"] | ||
|
||
# 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), | ||
] | ||
) | ||
bf_conditions = [ | ||
((bf_series > (-100 + i * 5)).fillna(True), i) for i in range(149, 0, -1) | ||
] + [((bf_series <= -100).fillna(True), 0)] | ||
|
||
pd_conditions = [((pd_series > (-100 + i * 5)), i) for i in range(149, 0, -1)] + [ | ||
(pd_series <= -100, 0) | ||
] | ||
|
||
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