Repository navigation
FIX-#7709: Return DataFrame from Series.str.extractall - #7722
FullStraing wants to merge 6 commits into
Conversation
Signed-off-by: Emirlan Togolokov <[email protected]>
…st_str_extractall Signed-off-by: Emirlan Togolokov <[email protected]>
ptimizeroracle
left a comment
There was a problem hiding this comment.
ran this change on main 7ca200b (the hunk copied into a scratch patch of StringMethods.extractall, MODIN_ENGINE=python, pandas 2.3.3). against pandas on 84 cases (4 inputs, 3 index shapes, 7 patterns with named groups, an optional group, no match and re.I): main returns a Series in all 84, with the change all 84 match on type and df_equals. the new test fails on main and passes with the change.
two things:
black --check --diff modin/pandas/series_utils.pyflags the hunk (blank line after the import, andreturn DataFrame(...)now fits on one line), solint (black and isort)should go red once ci runs. main's file is clean with the same black (26.10.1).([ab])(\d)matches 0 rows oftest_string_data, so that case compares two empty(0, 2)frames.([a-zA-Z])(\d)gives 1 row there.
(ai-assisted, checked by me)
Signed-off-by: Emirlan Togolokov <[email protected]>
Signed-off-by: Emirlan Togolokov <[email protected]>
Signed-off-by: Emirlan Togolokov <[email protected]>
|
Thanks for verifying the fix on 84 cases and for catching these two — both fixed: black formatting in series_utils.py (blank line after the import, single-line return) and the two-group pattern is now ([a-zA-Z])(\d) so it matches a row in test_string_data. |
ptimizeroracle
left a comment
There was a problem hiding this comment.
thanks, the pattern change is right, ([a-zA-Z])(\d) gives that case a row to compare.
one thing left at 8157edf: line 426 of modin/pandas/series_utils.py, the blank line after from .dataframe import DataFrame, has 8 spaces on it. black --check (26.10.1) still wants to reformat the file because of it, and flake8 reports W293 on the same line. an empty line there clears both.
i did not rerun the tests on the three new commits, they only touch formatting and the test pattern.
(ai-assisted, checked by me)
|
Thanks for catching that, @ptimizeroracle — line 426 in |
What do these changes do?
Fixes #7709.
Series.str.extractallwrapped the query compiler result in aSeries, so for a single capture group it returned aSeriesof shape(3,)while pandas always returns aDataFrame(with a MultiIndex of the original index and the match number), of shape(3, 1)in the reported example. This PR makesStringMethods.extractallinmodin/pandas/series_utils.pyreturn aDataFrameinstead, following the same local-import pattern as the siblingextractmethod.test_str_extractallinmodin/tests/pandas/test_series.pyis extended to compare the result against pandas witheval_generalfor both a single-group pattern (r"([ab])") and a two-group pattern (r"([ab])(\d)"), inside the existingwarns_that_defaulting_to_pandas_if(...)context, so the check that the operation defaults to pandas is kept.Note: the tests were not run locally — this change was made in a browser-only environment, so CI will run them.
flake8 modin/ asv_bench/benchmarks scripts/doc_checker.pyblack --check modin/ asv_bench/benchmarks scripts/doc_checker.pygit commit -sdocs/development/architecture.rstis up-to-date