赞
踩
提取日期操作参照→链接:https://blog.csdn.net/meiqi0538/article/details/82558000
- import numpy as np
- import pandas as pd
- from pandas import Series, DataFrame
- from datetime import datetime
-
- data = {'stamp': ['2016-12-01 00:00:00', '2016-12-01 01:05:10' ,'2016-12-01 02:10:20', '2016-12-01 03:15:30',
- '2016-12-01 04:20:40','2016-12-01 05:25:50','2016-12-01 06:30:00','2016-12-01 07:35:10',
- '2016-12-01 08:40:20','2016-12-01 09:45:30','2016-12-01 10:50:40','2016-12-01 11:55:50'],
- }
- df = pd.DataFrame(data)
- df
结果如下:
提取数据中日期:
- from pandas import to_datetime
- df_dt=to_datetime(df.stamp)
- s_y=df_dt.dt.year
- s_M
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。