I have a dataframe with people's CV data.
Among others, there's a column with years of experience, and a column with age.
Some people stated their age and experience in a way that experience > age. For example
experience=40, which is a problem.
I am trying to perform a following task:
experience > age, replace the value of
experience with an average experience of people of the same
age. For example if
experience with an average experience of all 30-year olds.
The problem is that I don't know how to obtain the age of a specific person in the slice
df[df['experience'] > df['age']].
AFAIK it could be done by something like this:
mask = (df['experience'] > df['age']) df['experience_cleaned'] = np.where(mask, df[df['age'] == age]['experience'].mean() ,df['experience'])
I would appreciate if you show me how it can be done, because I could use the technique to also preprocess more data in a similar way.