Skip to content

Commit 08507aa

Browse files
committed
Added more focus to data-processing examples by reorganizing repo. Added extra example in data-processing for joint CSV export.
1 parent a3f6740 commit 08507aa

File tree

12 files changed

+14
-0
lines changed

12 files changed

+14
-0
lines changed

examples/data-processing/process_data.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232

3333
df_concat = []
3434

35+
# -----------------------------------------
3536
for log_file in log_files:
3637
# open log file, get device id and extract dataframe with raw CAN data
3738
print(f"\nProcessing log file: {log_file}")
@@ -67,3 +68,16 @@
6768
# create a concatenated dataframe based on the individual dataframes
6869
df_concat = pd.concat(df_concat)
6970
print(f"\nConcatenated all {len(df_concat)} decoded frames into one dataframe")
71+
72+
# -----------------------------------------
73+
# restructure dataframe to have resampled signals in columns & save as CSV
74+
df_join = pd.DataFrame({"TimeStamp": []})
75+
for signal, signal_data in df_concat.groupby("Signal"):
76+
df_join = pd.merge_ordered(
77+
df_join,
78+
signal_data["Physical Value"].rename(signal).resample("1S").pad().dropna(),
79+
on="TimeStamp",
80+
fill_method="none",
81+
)
82+
83+
df_join.set_index("TimeStamp").to_csv("output_joined.csv")
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)