Extract a specific time attribute

Report a typo

We are trying to automate the task of fortune telling, and this specific type of future prediction happens to depend only on the day and the year of birth. Our data is stored in a DataFrame called df as

        date     name
0 1971-01-07    Julia
1 1971-10-02     Jake
2 1987-11-10     Rose
3 1984-10-02   Oliver
4 1984-12-19      Kat

Make two columns, firstly day and secondly year, and fill them with the respective extracted values from each date of birth. Print out the resultingDataFrame.

Write a program in Python 3
import pandas as pd

dob = ['1971-01-07', '1971-10-02', '1987-11-10', '1984-10-02', '1984-12-19', '1986-04-29', '1997-05-04', '2000-08-24', '1992-02-04', '1975-03-02']
df = pd.DataFrame({'date': pd.DatetimeIndex(dob),
'name': ['Julia', 'Jake', 'Rose', 'Oliver', 'Kat', 'Brandon', 'Isil', 'Le', 'Laura', 'Mark']})

#Your code here
___

Create a free account to access the full topic