-
Notifications
You must be signed in to change notification settings - Fork 1
/
helper_functions.py
43 lines (32 loc) · 1.13 KB
/
helper_functions.py
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
34
35
36
37
38
39
40
41
42
43
### Helper functions
# Last edit: 06.10.2023 08:58
import pandas as pd
def imports() -> tuple:
"""Load data from csv files
Returns:
tuple: Tuple of 3 DataFrame: X, Y, X_test
"""
X = pd.read_csv('data/train_values.csv')
Y = pd.read_csv('data/train_labels.csv')
X_test = pd.read_csv('data/test_values.csv')
return X, Y, X_test
def write_output(X_test, y_pred) -> None:
"""Create output.csv following drivendata.com submission standards and write file to disk
Args:
X_test (pd.Dataframe): Test dataset, x
y_pred (pd.Dataframe): Predictions, y
"""
# Create Dataframe for output
output_df = pd.DataFrame({'building_id': X_test['building_id'], 'damage_grade': y_pred})
# Write to csv
output_df.to_csv('output.csv', index=False)
def test_column_equality(a, b) -> None:
"""_summary_
Args:
a (pd.Dataframe): _description_
b (pd.Dataframe): _description_
"""
if a.columns.equals(b.columns):
print("Both DataFrames have the same columns.")
else:
print("The columns of the DataFrames are different.")