-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfeatures.py
More file actions
33 lines (26 loc) · 802 Bytes
/
features.py
File metadata and controls
33 lines (26 loc) · 802 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import pandas as pd
# Load data from CSV
df = pd.read_csv("9_10_2one.csv")
# Calculate features for every 5 rows
window_size = 10
num_windows = len(df) // window_size
results = []
for i in range(num_windows):
start_idx = i * window_size
end_idx = (i + 1) * window_size
window_df = df.iloc[start_idx:end_idx]
# Calculate features for this window
average_c4 = window_df['C4'].mean()
std_c4 = window_df['C4'].std()
diff_c4 = window_df['C4'].diff()
# Append results to list
results.append({
"Window": i + 1,
"Average_C4": average_c4,
"Std_C4": std_c4,
"Rate_of_Change_C4": diff_c4.mean()
})
# Convert results to DataFrame
results_df = pd.DataFrame(results)
# Save results to CSV
results_df.to_csv("alldata11.csv", index=False)