-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
404 lines (258 loc) · 9.93 KB
/
main.py
File metadata and controls
404 lines (258 loc) · 9.93 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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
"""
Libraries used are:
"""
from ast import Pass
from logging import exception
from tkinter.font import BOLD
from tkinter.tix import Tree
from turtle import end_fill
from typing import final
import pandas as pd
import colorama
from colorama import init
from colorama import Fore, Back, Style
import termcolor
from termcolor import cprint,colored
import pip
import matplotlib
from matplotlib import pyplot as plt
"""
=========================> Coloring Functions <====================
"""
# def Red():
# return Fore.RED + Style.BRIGHT
# def Blue():
# return Fore.BLUE + Style.BRIGHT
# def Green():
# return Fore.GREEN + Style.BRIGHT
# def Yellow():
# return Fore.YELLOW + Style.BRIGHT
# def Cyan():
# return Fore.CYAN + Style.BRIGHT
# def resetColor():
# return Fore.RESET + Style.RESET_ALL
# ----------------------------> End <---------------------------------
"""
--------------------> Data Class <--------------------
"""
class Data():
def __init__(self, path='', xlsxData='',csvData='',summary='',dataframe=''):
self.path = path
self.xlsxData = xlsxData
self.csvData = csvData
self.summary = summary
self.dataframe = dataframe
class Visualization():
def __init__(self, xaxis, yaxis, plottype):
self.xaxis = xaxis
self.yaxix = yaxis
self.plottype = plottype
def VisualMenu():
print("""\n\n
..................................................
{}\t1. Bar Plot
\t2. Scatter Plot
\t3. Box Plot
\t4. Histogram
\t5. Pie Chart
\t6. Line Chart
{}\t7. Exit{}
..................................................
\n\n""".format(Fore.CYAN, Fore.RED, Fore.RESET))
def VisualChoice():
while True:
Data.Visualization.VisualMenu()
plottype = str(input("Please Enter Plot Type : " ))
if plottype == '1':
print("\n\tPlotting Bar Plot.")
Data.Visualization.barplot()
elif plottype == '2':
print("\n\tPlotting Scatter Plot.")
Data.Visualization.scatterplot()
elif plottype == '3':
print("\n\tPlotting Box Plot.")
Data.Visualization.boxplot()
elif plottype == '4':
print("\n\tPlotting Histogram Chart.")
Data.Visualization.histogram()
elif plottype == '5':
print("\n\tPlotting Pie Chart")
Data.Visualization.piechart()
elif plottype == '6':
print("\n\tPlotting Line Chart")
Data.Visualization.linechart()
elif plottype == '7' or 'exit' or 'EXIT' or 'Exit':
print("\n\tExiting Visualization...")
break
else :
print("\n\tPlease Enter Correct Choice...")
def barplot():
xaxis = str(input("First Axis Name : "))
yaxis = str(input("Second Axis Name : "))
plt.bar(dataframe[xaxis], dataframe[yaxis])
plt.xlabel(xaxis)
plt.ylabel(yaxis)
plt.show()
def scatterplot():
try:
def TwoPoints():
xaxis = str(input("Enter xaxis Name : "))
yaxis = str(input("Enter yaxis Name : "))
a = dataframe[xaxis]
plt.scatter(a, dataframe[xaxis],color='blue')
plt.scatter(a, dataframe[yaxis],color='red')
plt.ylabel(yaxis)
plt.xlabel(xaxis)
plt.show()
TwoPoints()
except Exception as e:
print(e)
def boxplot():
try:
xaxis = str( input("Enter xaxis Name : "))
plt.boxplot(dataframe[xaxis])
plt.show()
except Exception as e:
print(e)
def histogram():
try:
axis = str(input("Enter Axis Name : "))
plt.hist(dataframe[axis])
plt.show()
except Exception as e:
print(e)
def piechart():
try:
axis = str(input("Enter Axis Name : "))
plt.pie(dataframe[axis])
plt.show()
except Exception as e :
print(e)
def linechart():
try:
xaxis = str(input("Enter xaxis name : "))
yaxis = str(input("Enter yaxis Name : "))
plt.plot(dataframe[xaxis], 'g')
plt.plot(dataframe[yaxis], 'r')
plt.xlabel(xaxis)
plt.ylabel(yaxis)
plt.show()
except Exception as e:
print(e)
def Get_Path(self):
print(end="\n\n")
path = input("Please Enter your data path : ")
print("\n")
Splitter = path.split(".")
# """
# =====================> Choice Menu Fuction Starts From Here <=====================
# """
def choiceMenu():
while True:
DataProcessing.ProcessingMenu()
print(end="\n\n")
choice = input("\nPlease Enter Your Choice : ")
if choice == '1':
print(end="\n\n\n")
head()
elif choice == '2':
print(end="\n\n\n")
tail()
elif choice == '3':
print(end="\n\n\n")
nullValues()
elif choice == '4':
print(end="\n\n\n")
describe()
elif choice == '5':
print(end="\n\n\n")
Data.Visualization.VisualChoice()
elif choice == '6' or 'Exit' or 'EXIT' or 'exit':
print(end="\n\n\n")
print("choice is 6. Breaking the loop.")
break
else:
print("Please enter correct choice....")
# """
# ******************************************************************************************************************************
# """
# """
# =====================> Processing Fuction Starts From Here <=====================
# """
def head():
print("\n\tPrinting First 5 Rows",end="\n\n")
print(dataframe.head())
def tail():
print("\n\tPrinting Last 5 Rows",end="\n\n")
print(dataframe.tail())
def nullValues():
try:
print("\n\tPrinting Null Values Data")
isnull = dataframe.isnull()
print("\n\n" , isnull , end="\n")
print("\n\nTotal Null Values: ",end="\n")
isnullSum = isnull.sum()
print("\n")
print(isnullSum)
except Exception as e:
print(e)
def describe():
desc = dataframe.describe()
print(desc)
print("\n\nColumns Present are : \n\n")
cprint(dataframe.columns,'yellow',attrs=['bold'])
print(end="\n\n")
# """
# ******************************************************************************************************************************
# """
try:
if 'xlsx' in Splitter:
global dataframe
dataframe = pd.read_excel(path)
choiceMenu()
elif 'csv' in Splitter:
dataframe = pd.read_csv(path)
choiceMenu()
else:
cprint("\n\n\tPlease Enter Correct File. \n\tOr Check extensions.")
cprint("\n\tUse only ", end="")
cprint(".CSV", 'red', attrs=[BOLD],end='')
cprint(" and ", end='')
cprint(".XLSX", 'red', attrs=[BOLD],)
print(end="\n\n")
except Exception as e:
print("\n\tFile " + Fore.RED + Style.BRIGHT + "\"{}\"".format(path) + Fore.RESET + Style.RESET_ALL + " is not present.")
print(end="\n\n")
#--------------------------------------------------------------------------------------------------------------
#--------------------------------------------------------------------------------------------------------------
class DataProcessing(Data):
#--------------------------------------------------------------------------------------------------------------
def ProcessingMenu():
print(Style.BRIGHT + """\n\n
=============================================={}
1. Show First Lines (head)
2. Show Last Lines (tail)
3. Show Null Values
4. Show Information
5. Graps and Visualization{}
6. Exit{}
==============================================
""".format(Fore.GREEN,Fore.RED,Fore.RESET))
#--------------------------------------------------------------------------------------------------------------
def xlsxDataFrame():
pass
def installPkgs():
try:
packageName = ['install', 'pandas', 'numpy', 'termcolor', 'colorama']
if hasattr(pip,'main'):
pip.main(packageName)
else:
pip._internal.main(packageName)
except Exception as e:
print(e)
#--------------------------------------------------------------------------------------------------------------
""" Main Function """
if __name__ == '__main__':
installPkgs()
obj = Data()
obj.Get_Path()