Commit
·
be26c88
1
Parent(s):
7f6e787
Update pre.py
Browse files
pre.py
CHANGED
@@ -30,4 +30,22 @@ def load_data(file):
|
|
30 |
|
31 |
def fill_missing_data(data, column_index, value):
|
32 |
data.iloc[:, column_index] = data.iloc[:, column_index].fillna(value)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
return data
|
|
|
30 |
|
31 |
def fill_missing_data(data, column_index, value):
|
32 |
data.iloc[:, column_index] = data.iloc[:, column_index].fillna(value)
|
33 |
+
return data
|
34 |
+
|
35 |
+
# Define a function to convert a string to camel case
|
36 |
+
def to_camel_case(s):
|
37 |
+
parts = s.split('_')
|
38 |
+
return ''.join([part.capitalize() for part in parts])
|
39 |
+
|
40 |
+
# Define the function to preprocess a CSV file
|
41 |
+
def preprocess_uploaded_file(uploaded_file):
|
42 |
+
file_content = uploaded_file.read()
|
43 |
+
processed_output = preprocess_csv(file_content)
|
44 |
+
processed_file = io.StringIO(processed_output.getvalue())
|
45 |
+
data = load_data(processed_file)
|
46 |
+
data = fill_missing_data(data, 4, 0)
|
47 |
+
data['Start datetime'] = pd.to_datetime(data['Start datetime'], errors='coerce')
|
48 |
+
data['End datetime'] = pd.to_datetime(data['End datetime'], errors='coerce')
|
49 |
+
data['Time spent'] = (data['End datetime'] - data['Start datetime']).dt.total_seconds()
|
50 |
+
data['Time spent(m:s)'] = pd.to_datetime(data['Time spent'], unit='s').dt.strftime('%M:%S')
|
51 |
return data
|