栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 前沿技术 > 大数据 > 大数据系统

pandas常用数据分析语法(四):时间处理

pandas常用数据分析语法(四):时间处理

pandas常用数据分析语法(四):时间处理
#数据类型转换
df.loc[:,'Arrest Date'] = pd.to_datetime(df['Arrest Date'])

#时间筛选
df= df.loc[(df.loc[:,'Arrest Date']<=pd.Timestamp('2019-1-1')),:]
df_2018 = df.loc[df.loc[:,'Arrest Date'].apply(lambda x: x.year == 2018),:]
id_a=data.loc[:,'Arrest Date'].apply(lambda x: x.year <=2019  and x.month==5)
id_b=data.loc[:,'Arrest Date'].between(pd.Timestamp('2019-4-30'),pd.Timestamp('2019-5-04'))
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/742534.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号