Commit 1ca8e232 authored by Hendrik Becker's avatar Hendrik Becker
Browse files

Export functions in src

parent 57b58803
This diff is collapsed.
delete me, just to keep the folder in git
\ No newline at end of file
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import os
# function loads the preprocessed data into DataFrames.
def import_preprocessed_data():
path_0 = '../data/preprocessed/clusters/0/'
path_1 = '../data/preprocessed/clusters/1/'
path_2 = '../data/preprocessed/clusters/2/'
dfs_c_0 = []
dfs_c_1 = []
dfs_c_2 = []
dfs_c_0_grouped = []
dfs_c_1_grouped = []
dfs_c_2_grouped = []
csv_files_0 = [csv for csv in os.listdir(path_0) if csv.endswith('.csv')]
csv_files_1 = [csv for csv in os.listdir(path_1) if csv.endswith('.csv')]
csv_files_2 = [csv for csv in os.listdir(path_2) if csv.endswith('.csv')]
for file in csv_files_0:
# import DataFrame
df = pd.read_csv(path_0 + file)
if file.startswith('g_'):
for file in csv_files_1:
# import DataFrame
df = pd.read_csv(path_1 + file)
if file.startswith('g_'):
for file in csv_files_2:
# import DataFrame
df = pd.read_csv(path_2 + file)
if file.startswith('g_'):
return dfs_c_0, dfs_c_1, dfs_c_2, dfs_c_0_grouped, dfs_c_1_grouped, dfs_c_2_grouped
# function calculates the empties of a container.
def calculate_empties(df, threshold):
empties_indices = []
for idx,val in enumerate(df['inter_pol']):
if idx != 0 and (df['inter_pol'][idx-1]*threshold < (df['inter_pol'][idx])) and (df['inter_pol'][idx] > 120):
# filter out double values
for idx,val in enumerate(empties_indices):
if idx !=0 and (empties_indices[idx] - empties_indices[idx-1]) < 3:
return empties_indices
# function adds the calculated emptied to the container DataFrame.
def add_empties_column(df, values):
df_final = df
df_final['empties'] = 0
for i in range(0, len(df), 1):
if i in values:
df_final['empties'][i] = 1
return df_final
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment