-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdata_description.py
More file actions
76 lines (64 loc) · 2.55 KB
/
data_description.py
File metadata and controls
76 lines (64 loc) · 2.55 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
import pandas as pd
class DataDescription:
tasks = [
'\n1. Describe a specific Column',
'2. Show Properties of Each Column',
'3. Show the Dataset'
]
def __init__(self, data):
self.data = data
# The function that prints the database on the command line.
def showDataset(self):
while(1):
try:
rows = int(input(("\nHow many rows(>0) to print? (Press -1 to go back) ")))
if rows == -1:
break
if rows <= 0:
print("Number of rows given must be +ve...")
continue
print(self.data.head(rows))
except ValueError:
print("Numeric value is required. Try again....")
continue
break
return
# function to print all the columns
def showColumns(self):
for column in self.data.columns.values:
print(column, end=" ")
# function to describe the dataset or any specific column.
def describe(self):
while(1):
print("\nTasks (Data Description)")
for task in self.tasks:
print(task)
while(1):
try:
choice = int(input(("\n\nWhat you want to do? (Press -1 to go back) ")))
except ValueError:
print("Integer Value required. Try again.....\U0001F974")
continue
break
if choice==-1:
break
elif choice==1:
self.showColumns()
while(1):
describeColumn = input("\n\nWhich Column? ").lower()
try:
# describe() function is used to tell all the info regarding any specific column.
print(self.data[describeColumn].describe())
except KeyError:
print("No Column present with this name. Try again....\U0001F974")
continue
break
elif choice==2:
# describe() function is used to tell all the info about the database.
print(self.data.describe())
print("\n\n")
print(self.data.info())
elif choice==3:
self.showDataset()
else:
print("\nWrong Integer value!! Try again..\U0001F974")