[FEA] Support an “extractall” method
- Dominant language
- C++
- Stars
- 9.8k
- Forks
- 1.1k
- Avg merge
- 3d 6m
- Merged PRs (30d)
- 278
Description
I’d like for cuDF to support an “extractall” method similarly to how Pandas functions
# Example:
```
cudfSeries = cudf.Series(["a1a2", "b1", "c1"], index=["A", "B", "C"], dtype="str")
cudfSeries
cudf_two_groups = "(?P[a-z])(?P[0-9])"
cudfSeries.str.extract(cudf_two_groups, expand=True)
cudfSeries.str.extractall(cudf_two_groups)
```
# Result:
```
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
in
----> 1 cudfSeries.str.extractall(cudf_two_groups)
AttributeError: 'StringMethods' object has no attribute 'extractall'
```
**Pandas does this by extracting using ‘extractall’ is always a DataFrame with a MultiIndex on its rows. The last level of the MultiIndex is named match and indicates the order in the subject.:**
pandasSeries = pd.Series(["a1a2", "b1", "c1"], index=["A", "B", "C"], dtype="string")
pandasSeries
pandas_two_groups = "(?P[a-z])(?P[0-9])"
pandasSeries.str.extract(pandas_two_groups, expand=True)
pandasSeries.str.extractall(pandas_two_groups)
# Output
```
letter digit
match
_________________________
A 0 a 1
1 a 2
B 0 b 1
C 0 c 1
```
Contributor guide
Assessment
This issue has not been assessed yet.