Reputation: 365
I want to extract a number of squared meters from a house description column. For example, I used:
df['description'].str.extract('(\d\,\d{1,3}\s?[sS])', expand=True)
to extract 3000 from a string that looks like "The house is 3,000 square meters".
What if I wanted to extract 800 square meters? So a condition that does not involve the comma. How would I add that to the condition. Sorry I looked around and still couldn't figure it out.
Upvotes: 1
Views: 293
Reputation: 323326
I am using str.findall
s=pd.Series(['llll llll llll 100,000.00 lll lll ll ','xyz 800 bgm bhd','80','1,000.00 and 10'])
s.str.findall(r'(?:[,\d]+.?\d*)')
0 [100,000.00]
1 [800]
2 [80]
3 [1,000.00, 10]
dtype: object
Upvotes: 1