2021-02-26
阅读量:
428
python如何将数据和时间分成单独的功能
问:
python如何将数据和时间分成单独的功能
答:
# Create date and time with dataframerng = pd.DataFrame()rng['date'] = pd.date_range('1/1/2011', periods = 72, freq ='H')# Print the dates in dd-mm-yy formatrng[:5]# Create features for year, month, day, hour, and minuterng['year'] = rng['date'].dt.yearrng['month'] = rng['date'].dt.monthrng['day'] = rng['date'].dt.dayrng['hour'] = rng['date'].dt.hourrng['minute'] = rng['date'].dt.minute# Print the dates divided into featuresrng.head(3)
输出:

52.1739
1
0
关注作者
收藏
评论(0)
发表评论
暂无数据
推荐帖子
0条评论
0条评论
0条评论

