题目
题目
单项选择题

 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?

选项
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')
查看解析

查看解析

标准答案
Please login to view
思路分析
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

登录即可查看完整答案

我们收录了全球超50000道考试原题与详细解析,现在登录,立即获得答案。

更多留学生实用工具

加入我们,立即解锁 海量真题独家解析,让复习快人一步!