I have a pandas dataframe with a salary column which contains values like:
£36,000 - £40,000 per year plus excellent bene..., £26,658 to £32,547 etc
I isolated this column and split it with the view to recombining into the data frame later via a column bind in pandas.
I now have an object with columns like the below. The columns I split the original data frame column I think are blank because I didn't specify them (I called df['salary']=df['salary'].astype(str).str.split()
)
So my new object contains this type of information:
[£26,658, to, £32,547], [Competitive, with, Excellent, Benefits]
What I want to do is:
- Create three columns called minvalue and maxvalue and realvalue
- List items starting with £ (something to do with
"^£"
? - Take till the end of the items found ignoring the £ (get the number out) (something to do with
(substr(x,2,nchar(x)))
? - If there are two such items found, call the first number "minvalue" and call the second number "maxvalue" and put it below the right column. If there is only one value in the row, put it below the realvalue column.
I am very new to pandas and programming in general, but keen on learning, your help would be appreciated.