'Regex to capture entire string in python panda series
I have a sample series:
s = pd.Series(['Complexity Level 1', 'RandomName', 'I-Invoice Submission test', 'I-test2', 'I-string with multiple words'])
I'm trying to capture only strings that begin with "I-". Using extract.
extract1 = s.str.extract(r'I-(\w+)')
Current Output:
0
0 NaN
1 NaN
2 Invoice
3 test2
4 string
It's currently only extracting the first word. But I want all words and white space after the identifier. This could be up to 5 words
Is this a regex adjustment or is there a better method?
What I want is:
0
0 NaN
1 NaN
2 Invoice Submission test
3 test2
4 string with multiple words
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
