我有一个日期字符串,并希望将其转换为日期类型:
我试图使用datetime.datetime.strptime和我想要的格式,但它返回转换的时间.
when = alldates[int(daypos[0])]
print when, type(when)
then = datetime.datetime.strptime(when, '%Y-%m-%d')
print then, type(then)
Run Code Online (Sandbox Code Playgroud)
这是输出返回的内容:
2013-05-07 <type 'str'>
2013-05-07 00:00:00 <type 'datetime.datetime'>
Run Code Online (Sandbox Code Playgroud)
我需要删除时间:00:00:00.
我正在尝试根据键(target_names,target和DESCR)加载sklearn.dataset并丢失一列.我已经尝试了各种方法来包含最后一列,但有错误.
import numpy as np
import pandas as pd
from sklearn.datasets import load_breast_cancer
cancer = load_breast_cancer()
print cancer.keys()
Run Code Online (Sandbox Code Playgroud)
键是['target_names','data','target','DESCR','feature_names']
data = pd.DataFrame(cancer.data, columns=[cancer.feature_names])
print data.describe()
Run Code Online (Sandbox Code Playgroud)
使用上面的代码,它只返回30列,当我需要31列.将scikit-learn数据集加载到pandas DataFrame中的最佳方法是什么.