-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathplotting.py
37 lines (32 loc) · 1.03 KB
/
plotting.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
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
class Plotting:
def __init__(self, plot_option, x, data):
self.plot_option = plot_option
self.x = x
self.data = data
def plot(self):
if self.plot_option == 1:
return self.histogram()
elif self.plot_option == 2:
return self.boxplot()
elif self.plot_option == 3:
return self.barplot()
else:
return "Invalid plot option"
def histogram(self):
self.data[self.x].hist()
plt.title("Histogram of " + self.x)
plt.show()
return self.data[self.x].describe()
def boxplot(self):
self.data.boxplot(column=self.x)
plt.title("Boxplot of " + self.x)
plt.show()
return self.data[self.x].describe()
def barplot(self):
pd.DataFrame(self.data[self.x].value_counts(normalize=True)).plot.bar()
plt.title("Bar plot of "+self.x)
plt.show()
return self.data[self.x].describe()