I have a column in my pandas df that looks like this:
Cycle 1 (0 h)
A
B
C
Cycle 2 (0 h 43 min)
A
B
C
I'm trying to match 'Cycle' and extract the digits. Ideally, I'd like for my output to look like this:
0
A
B
C
0,43
A
B
C
I've tried:
df['1'] = df['1'].str.contains('Cycle', regex=True).str.extract('(\d+)')
But it gets rid of the Cycle line completely - I thought that after extracting the digits I could use str.split() and retain only the pertinent numbers which I could then separate by a comma. But I can't seem to extract the numbers.