import os
filepath = os.path.join(os.getcwd(), 'sample_wind_data.csv')
import pandas as pd
df = pd.read_csv(filepath)
df1 = df.head(50)
indices = []
index_bins = []
start = False
for index, row in df1.iterrows():
if row['AVGspeed'] > 8 and start == False:
start = True
index_bins.append(index)
elif row['AVGspeed'] > 8 and start == True:
index_bins.append(index)
else:
if len(index_bins) >= 3:
indices += index_bins
start = False
index_bins = []
df2 = df1.loc[indices]
Example output
import os
filepath = os.path.join(os.getcwd(), 'sample_wind_data.csv')
import pandas as pd
df = pd.read_csv(filepath)
df1 = df.head(50)
indices = []
index_bins = []
start = False
for index, row in df1.iterrows():
if row['AVGspeed'] > 8 and start == False:
start = True
index_bins.append((row['Date Time'], row['AVGspeed']))
elif row['AVGspeed'] > 8 and start == True:
index_bins.append((row['Date Time'], row['AVGspeed']))
else:
if len(index_bins) >= 3:
indices.append(index_bins)
start = False
index_bins = []
pd.Series(indices)
Example output