Questions
Questions
Single choice

 Supposed the 'date' column in the DataFrame shown has a dtype of object (i.e. string). How can it be converted to Pandas's datetime64 datatype?

Options
A.df['date']=pd.to_datetime(df['date'],format='%Y').year
B.df['date']=pd.to_datetime(df['date'],format='%Y').dt.year
C.df['date']=pd.to_datetime(df['date'],format='%Y')
D.df['date']=pd.to_datetime(df['date'],format='%y')
View Explanation

View Explanation

Verified Answer
Please login to view
Step-by-Step Analysis
Question restated: The DataFrame has a 'date' column with dtype object (strings). We want to convert it to Pandas datetime64. Option 1: df['date']=pd.to_datetime(df['date'],format='%Y').year This would attempt to parse with a four-digit year and then access the .year attribute, producing a scalar or a series of integers, not a......Login to view full explanation

Log in for full answers

We've collected over 50,000 authentic exam questions and detailed explanations from around the globe. Log in now and get instant access to the answers!

More Practical Tools for Students Powered by AI Study Helper

Join us and instantly unlock extensive past papers & exclusive solutions to get a head start on your studies!