Reputation: 629
I have a data frame with a column that has numbers in format x.x or x.xx randomly embedded in a string. I can separately extract such numbers using
pd[colName].str.extract('(\d\.\d)') or
pd[colName].str.extract('(\d\d\.\d)')
And then merging the two results. But how would I combines these two conditions together using some sort of 'or' condition to achieve the same in one go.
Upvotes: 1
Views: 625
Reputation: 210832
Try this:
pd[colName].str.extract('(\d\.\d{1,2})')
Upvotes: 2