我使用pandas来读取csv文件,其中列名是日期时间( date time ),类似于2017-01-02。我尝试使用以下代码将列类型更改为datatime64[D]:但是,它会引发强制转换错误:TypeError: Cannot cast Index to dtype datetime64[D]‘
当我将代码更<e
_libs.tslib.array_with_unit_to_datetimepandas._libs.tslibs.np_datetime.OutOfBoundsDatetime: cannot convert input with unit 's' 尝试将pandas列转换为日期时间格式时我检查了这个答案Convert unix time to readable date in pandas dataframe 但这并没有帮助
我通常调用一些csv文件中的数据,并使用pandas.to_datetime函数将日期列更改为datetime格式,以便进行进一步的数据处理。"]= df1["Date"].apply(pd.to_datetime)
# after this change, the type(df1["Date"][0]) becomes pandas</e
我正在使用由pandas读取的CSV文件作为数据框架,我希望有一个每列所有数据类型的列表作为输出-这就是我到目前为止所得到的-我遇到的问题是,对于所有不是浮点数/整数的数据类型,它只返回dtype('O我的代码如下所示:datatypes = dataframe.dtypes #here we find out how wh