Python提取特定时间段内数据的方法实例
python提取特定时间段内的数据
尝试一下:
data['Date']=pd.to_datetime(data['Date']) data=data[(data['Date']>=pd.to_datetime('20120701'))&(data['Date']<=pd.to_datetime('20120831'))]
实际测试
''' Createdon2019年1月3日 @author:hcl ''' importpandasaspd importmatplotlib.pyplotasplt data_path='one_20axyz.csv' if__name__=='__main__': msg=pd.read_csv(data_path) #ID_set=set(msg['Time'].tolist()) #ID_list=list(ID_set) #print(len(msg['Time'].tolist()),len(ID_list),len(msg['Time'].tolist())/len(ID_list))#打印数据量多少秒平均每秒多少个 #print(msg.head(10)) #left_a=msg[msg['leg']==1]['az'] #right_a=msg[msg['leg']==2]['az'] #plt.plot(left_a,label='left_a') #plt.plot(right_a,label='right_a') #plt.legend(loc='best') #plt.show() left_msg=msg[msg['leg']==1]#DataFrame data=left_msg[(pd.to_datetime(left_msg['Time'],format='%H:%M:%S')>=pd.to_datetime('16:23:42',format='%H:%M:%S'))&(pd.to_datetime(left_msg['Time'],format='%H:%M:%S')<=pd.to_datetime('16:23:52',format='%H:%M:%S'))] #print(msg.head()) print(data)
输出:
TimeIDlegaxayazaRssi 116:23:42510.6855-0.69150.11200.980116-34 316:23:42510.6800-0.64400.13650.946450-31 516:23:42510.7145-0.72400.10951.023072-34 716:23:42510.7050-0.69100.10800.993061-30 916:23:42510.7120-0.64000.09200.961773-31 1016:23:42510.7150-0.68100.12900.995805-34 1216:23:42510.7250-0.66550.18901.002116-32 1316:23:42510.7160-0.70650.10001.010840-31 1516:23:42510.7545-0.69900.17151.042729-30 1716:23:42510.7250-0.69100.13251.010278-31 1916:23:42510.7520-0.72600.18201.060992-33 2116:23:42510.7005-0.71500.06051.002789-33 2316:23:42510.7185-0.66300.14300.988059-30 2516:23:42510.7170-0.70400.09201.009044-34 2716:23:42510.7230-0.68100.10600.998862-31 2916:23:42510.7230-0.67200.09400.991539-31 3116:23:42510.6955-0.69750.07200.987629-33 3216:23:42510.7430-0.68950.14951.024602-34 3416:23:43510.7360-0.68550.12001.012920-32 3616:23:43510.7160-0.70000.13301.010121-30 3816:23:43510.7095-0.71650.10901.014221-31 4016:23:43510.7195-0.68950.12701.004599-34 4416:23:43510.7315-0.68550.10001.007473-34 4616:23:43510.7240-0.70200.09601.013013-31 4816:23:43510.7240-0.70100.09701.012416-32 5016:23:43510.7380-0.68200.14801.015713-34 5216:23:43510.7285-0.69900.09901.014453-33 5316:23:43510.7160-0.70050.16301.014852-30 5516:23:43510.7175-0.69400.07351.000922-29 5716:23:43510.7140-0.71700.09601.016416-28 ......................... 28516:23:51510.0550-1.02050.09551.026433-35 28716:23:51510.0670-1.01750.09151.023801-22 28916:23:51510.0595-1.00900.10251.015937-24 29116:23:51510.0605-0.99700.09051.002925-32 29316:23:51510.0650-1.01850.07401.023251-31 29516:23:51510.0595-0.99150.09450.997769-35 29816:23:51510.0420-1.01050.09701.016013-18 30016:23:51510.0545-1.04400.07951.048440-21 30216:23:51510.0460-0.99150.07650.995510-30 30416:23:51510.0650-1.01000.08101.015326-30 30616:23:51510.0530-1.02400.07651.028220-34 30816:23:51510.0490-1.00600.07851.010247-21 31016:23:52510.0490-1.01550.07601.019518-24 31216:23:52510.0370-0.98700.06600.989896-30 31316:23:52510.0400-1.01850.04351.020213-30 31416:23:52510.0450-1.00700.05401.009450-34 31616:23:52510.0420-0.98000.05950.982703-34 31816:23:52510.0400-1.00000.05951.002567-20 32016:23:52510.0355-1.00250.06351.005136-20 32216:23:52510.0430-0.99400.07350.997641-30 32416:23:52510.0480-1.01350.06401.016652-33 32616:23:52510.0440-1.00350.06701.006696-33 32816:23:52510.0455-1.00900.06001.011806-21 33016:23:52510.0420-1.00050.06051.003207-15 33216:23:52510.0510-1.01650.06701.019981-29 33416:23:52510.0300-1.00400.04601.005501-30 33616:23:52510.0370-1.01300.05001.014908-34 33816:23:52510.0500-1.00100.05301.003648-20 34116:23:52510.0400-0.96300.06150.965790-21 34316:23:52510.0365-1.02950.04101.030962-30 [176rowsx8columns]
总结
以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作具有一定的参考学习价值,谢谢大家对毛票票的支持。如果你想了解更多相关内容请查看下面相关链接
声明:本文内容来源于网络,版权归原作者所有,内容由互联网用户自发贡献自行上传,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任。如果您发现有涉嫌版权的内容,欢迎发送邮件至:czq8825#qq.com(发邮件时,请将#更换为@)进行举报,并提供相关证据,一经查实,本站将立刻删除涉嫌侵权内容。