I have got a huge csv file which contains data about a bicycle being driven. So I got a time column in seconds and a Speed column. I would like to check for specific pattern in the data, in order to conclude what happend on the road.
For example driving torwards a traffic light:
I got this so far:
import pandas as pd
df = pd.read_csv('.csv', usecols = ['time', 'speed'])
df['accelerating'] = df['speed'].diff() > 0
And I want something like this:
df_traffic_light = df.loc[df['speed'] < 15 & accelerating == False #driving torwards the traffic light;
& df.loc[df['speed']< 1 #getting really slow or Standing still;
& df.loc[df['speed'] > 5 & accelerating == True #for light switched to green and starting again
Expected Output:
time speed acceleration
0 5.000 14.0 false
1 7.056 12.0 false
2 10.097 8.0 false
3 12.131 1.0 false
4 14.165 0.0 false
5 16.201 0.0 false
6 18.236 2.0 true
7 20.267 4.0 true
I tried it with dataframe.rolling but didnt work out quite well. Any ideas how I solve this?
Aucun commentaire:
Enregistrer un commentaire