Question: We have a dataframe 'customers' with a column Birthdate' containing the birthdate of customers in the format YYYY - MM - DD ' .

We have a dataframe 'customers' with a column "Birthdate' containing the birthdate of customers in the format "YYYY- MM-DD'. We want to calculate the age of each customer and create a new column 'Age'. We have today's year in a variable named 'year' as a numerical number. Which code is correct?
customers('Age')= pd.to_datetime(customers['Birthdate'].dt year - customer['year']max()
customers ['Age']= customers['year']- pd.to_datetime(customers['Birthdate']).dt.year
customers ['Age']= customer.dt.year - pd.to_datetime(customers ['Birthdate'].dt.year
customers ['Age'](pd.to datetime(customers ['Birthdate']).year

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!