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'))