I have a dataframe which looks like this:
description
1906 RES 330 ML
1906 RES 330ML
RES 335 c/6
RES 332 c/12
I want to extract the three consecutive digits of numbers and save it in a new column 'volume'. My code is like this:
df['volume'] = df['description'].str.extract('([([\d]*[\d]){3,3}?])')
EXPECTED RESULTS SHOULD BE LIKE THIS:
volume
330
330
335
332
However, it gives the results like this:
volume
1906
1906
335
332
Can anyone help me fix this code? Thanks so much!!!