Splitting the prices (Number values £s) from within the text?

  jupyter-notebook, pandas, python

I have a table column (df1[‘income’]), shown below, and I want to extract just the first prices.

Income
Approx £1,000000 £2 psf
£1,000,050 £4psf
£15000000 £3psf
Expected £520000 £3.2 psf
df1['Income'].str.split(r'£.........',)
pattern = re.compile(r'£.........')
matches = pattern.finditer(str(df1['Income']))

for match in matches:
    print(match)

The issue is the first code extracts both prices and the second code removes all the characters, rather than splitting them how I’d want.

All help greatly appreciated, thanks.

Source: Python Questions

LEAVE A COMMENT