data['交易时间'] = pd.to_datetime(data['交易时间'])
源自利用python进行数据分析P304
使用python的datetime包中的
strptime函数,datetime.strptime(value,’%Y/%M/%D’)
strftime函数,datetime.strftime(‘%Y/%M/%D’)
注意使用datetime包中后面的字符串匹配需要和原字符串的格式相同,才能转义过来,相当于yyyy-mm-dd格式的需要按照’%Y-%M-%D’来实现,而不是’%Y/%M/%D’
data['交易时间']=data['交易时间'].apply(lambda x:datetime.strptime(x,'%Y-%m-%d %H:%M:%S'))
data = data.drop_duplicates()
pandas.read_csv(filepath_or_buffer: Union[str, pathlib.Path, IO[~AnyStr]], sep=',', delimiter=None, header='infer', names=None, index_col=None, usecols=None, squeeze=False, prefix=None, mangle_dupe_cols=True, dtype=None, engine=None, converters=None, true_values=None, false_values=None, skipinitialspace=False, skiprows=None, skipfooter=0, nrows=None, na_values=None, keep_default_na=True, na_filter=True, verbose=False, skip_blank_lines=True, parse_dates=False, infer_datetime_format=False, keep_date_col=False, date_parser=None, dayfirst=False, cache_dates=True, iterator=False, chunksize=None, compression='infer', thousands=None, decimal: str = '.', lineterminator=None, quotechar='"', quoting=0, doublequote=True, escapechar=None, comment=None, encoding=None, dialect=None, error_bad_lines=True, warn_bad_lines=True, delim_whitespace=False, low_memory=True, memory_map=False, float_precision=None)[source]
https://includestdio.com/1419.html
for index, row in df.iterrows():
print row['c1'], row['c2']
Output:
10 100
11 110
12 120
df.set_index("A")["B"].to_dict()