I have some % cases as the follow -
12.02
16.59
81.61%
45
24.812
51.35
19348952
88.22
0
000
021
.85%
100
I want to match all the percentages type except anything larger than 100. Expected Output:
12.02
16.59
81.61
45
24.812
51.35
88.22
0
000
21
.85
100
I have tried (Regular Expression for Percentage of marks). But this one fails to get all the cases that I want. Also, I am replacing the non-match with empty string. So my code in python looks like like this -
pattern=r'(\b(?<!\.)(?!0+(?:\.0+)?%)(?:\d|[1-9]\d|100)(?:(?<!100)\.\d+)?$)'
df['Percent']=df['Percent'].astype(str).str.extract(pattern)[0]
Many thanks.
Edit: The solution (by @rv.kvetch) matches most of the edge cases except the 0 ones but I can work with that limitation. The original post had requirement of not matching 0 case or 0%.