I have this data:
Pandas Dataframe
I need to create a new column in python that returns the number of days between the End Date of the task Technical Analysis and the End Date of the task Approval for the different Project Id’s.
I’ve tried this approach:
approval_date = df.loc[df[‘Task Name’] == ‘Approval’, ‘End Date’].values[0]
technical_analysis_date = df.loc[df[‘Task Name’] == ‘Technical Analysis’, ‘End Date’].values[0]
nr_days_negotiation = (pd.to_datetime(approval_date) – pd.to_datetime(technical_analysis_date)).days
df[‘Nr_days_negotiation’] = nr_days_negotiation
But it’s returning the same value of number of days for all the different project id’s…
What I want to achieve is this:
The column that I need to create
How can I do this?
Beatriz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.