Skip to content

Commit 7e6518f

Browse files
committed
Cleaned up main body.
1 parent cfd2556 commit 7e6518f

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

PostProcessing/dataframes.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import pandas as pd
22

3+
from typing import Tuple
34

45
def repair_dropped_frames(df: pd.DataFrame) -> pd.DataFrame:
56
pass
67

8+
79
# Function to find the largest value in the first entry of all dataframes
810
def find_largest_first_entry(dfs):
911
largest_value = float('-inf')
@@ -13,6 +15,7 @@ def find_largest_first_entry(dfs):
1315
largest_value = first_entry
1416
return largest_value
1517

18+
1619
# Function to find the smallest value in the last entry of selected dataframes
1720
def find_smallest_last_entry(dfs):
1821
smallest_value = float('inf')
@@ -22,22 +25,24 @@ def find_smallest_last_entry(dfs):
2225
smallest_value = last_entry
2326
return smallest_value
2427

28+
2529
# Function to find the largest & smallest value in the first and last entry of dataframes
26-
def compute_time_range(dfs):
30+
def compute_time_range(dfs) -> Tuple[int, int]:
2731
# Find the lowest and highest numbers in all the data frames
2832
lower_value = find_largest_first_entry(dfs)
2933
higher_value = find_smallest_last_entry(dfs)
3034

3135
# return the results
32-
return (lower_value, higher_value)
36+
return lower_value, higher_value
37+
3338

3439
# Function to trim dataframes based on specified values
3540
def trim_into_interval(dfs, min_common, max_common, threshold):
3641
trimmed_dataframes = []
3742
# import pdb;pdb.set_trace()
3843
for df in dfs:
39-
start = df[(df.iloc[:, 0] >= min_common - threshold) & (df.iloc[:, 0] <= min_common + threshold)]
40-
end = df[(df.iloc[:, 0] >= max_common - threshold) & (df.iloc[:, 0] <= max_common + threshold)]
44+
start: pd.DataFrame = df[(df.iloc[:, 0] >= min_common - threshold) & (df.iloc[:, 0] <= min_common + threshold)]
45+
end: pd.DataFrame = df[(df.iloc[:, 0] >= max_common - threshold) & (df.iloc[:, 0] <= max_common + threshold)]
4146
trimmed_df = df[(df.iloc[:, 0] >= start.iloc[0, 0]) & (df.iloc[:, 0] <= end.iloc[0, 0])].reset_index(drop=True)
4247
trimmed_dataframes.append(trimmed_df)
4348
return trimmed_dataframes

0 commit comments

Comments
 (0)