-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
128 lines (94 loc) · 3.48 KB
/
main.py
File metadata and controls
128 lines (94 loc) · 3.48 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
###### Imports #######
import pandas as pd
import matplotlib.pyplot as plt
import time
from textwrap import dedent
from pathlib import Path
from functions import *
###### Data loading #######
print('To use this program, first you need to put the excel file you want to analyze in the same directory of it.')
table_name = input('Type the name of the Excel file you want to analyze (without the .xlsx extension): ').strip()
data = load_data(table_name=table_name)
print(f"\nFile loaded successfully! [{data.shape[0]} rows x {data.shape[1]} columns]")
see_data = input("\nDo you want to see the data? (y/n): ")
if see_data.lower() == 'y':
print(data)
else:
print("Data will not be displayed.")
###### Data analysis #######
while True:
print("\n======== Data analysis ========")
print(dedent('''
What do you want to do?
1. Filter data by column value
2. Update values
3. Calculate statistics
4. See data
5. Exit
'''))
choice = input("Enter the number of your choice: ").strip()
if choice == '1':
filter_data(data=data)
elif choice == '2':
print(dedent('''
Choose what you want to update:
[A] Row
[B] Column
[C] Conditional update'''))
print("\nExample of conditional update:")
print('Modify the "Tax Multiplier" in every row where the "Type" column is "Service" to 1.5')
while choice.upper() not in ['A', 'B', 'C']:
choice = input("\nEnter your choice (A/B/C) or type 'exit' to quit: ").strip()
if choice.upper() == 'A':
update_row(data=data)
break
elif choice.upper() == 'B':
modify_column(data=data)
break
elif choice.upper() == 'C':
conditional_update(data=data)
break
elif choice.lower() == 'exit':
print("Exiting the update menu.")
break
else:
print("Invalid option. Try again...")
elif choice == '3':
print(dedent('''
Choose the statistic you want to calculate:
[A] Mean
[B] Median
[C] Mode
[D] Standard Deviation
[E] Maximum
[F] Minimum
'''))
while choice.upper() not in ['A', 'B', 'C', 'D', 'E', 'F']:
choice = input("\nEnter your choice (A/B/C/D): ")
if choice.upper() == 'A':
calculate_mean(data=data)
break
elif choice.upper() == 'B':
calculate_median(data=data)
break
elif choice.upper() == 'C':
calculate_mode(data=data)
break
elif choice.upper() == 'D':
calculate_std(data=data)
break
elif choice.upper() == 'E':
calculate_max(data=data)
break
elif choice.upper() == 'F':
calculate_min(data=data)
break
else:
print("Invalid option. Try again...")
elif choice == '4':
print(data)
elif choice == '5':
print("Exiting the program. Goodbye!")
break
else:
print("Invalid option. Try again...")