With sample dataset one can achieve desired result as follows:
>>> df = pd.DataFrame('3" deep, 4 inches deep, 5" depth'.split(','), columns=['Depth']) >>> df Depth 0 3" deep 1 4 inches deep 2 5" depth >>> df.Depth.str.extract('(\d+)') 0 0 3 1 4 2 5EDIT: if numeric value is needed then it probably should be int (or float) datatype. So one can do:
>>> df['Depth_number'] = df.Depth.str.extract('(\d+)').astype(int) >>> df Depth Depth_number 0 3" deep 3 1 4 inches deep 4 2 5" depth 5 >>> df.dtypes Depth object Depth_number int64 dtype: object
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.