I am wondering how to use regex remove any non-numeric chars while only selecting non-empty and spaces (a single value may contain one or multiple spaces) values for a series in a more efficient way,
df['numeric_no'] = df['id'].apply(lambda x: re.sub("[^0-9]", "", x))
df = df[(df['numeric_no'] != '') & (df['numeric_no'] != ' ')]
some sample data for the df
numeric_no
B-27000
44-11-E
LAND-11-4
17772A
88LL9A
321LP-3
UNIT 9 CAM -00-12
WWcard_055_34QE
EE119.45
aaa
b b
the result will look like
numeric_no
27000
4411
114
17772
889
3213
90012
05534
119.45
re.sub(r"(\d+(?:\.\d+)?)|.", "$1", x)