Types and formats

Report a typo

Suppose that we store the name along with the date of birth, which is recognized as a string (in DD/MM/YYYY format), in a DataFrame:

        date     name
0 2000-03-04    Sarah
1 2003-03-05    Jenny
2 2002-03-06  Roberta

Convert the date column to the datetime64[ns] type and change the format to YYYY-MM-DD. Print the resulting DataFrame.

Write a program in Python 3
import pandas as pd

df = pd.DataFrame({'date': ['4/03/2000', '5/03/2003', '6/03/2002', '6/03/2001', '1/01/2000', '11/09/2008'],
'name': ['Sarah', 'Jenny', 'Roberta', 'Alex', 'Marina', 'Jack']})

# Your code here
___

Create a free account to access the full topic