In [12]:
import matplotlib
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import pandas as pd
#%metplotlib inline
#%matplotlib notebook
%matplotlib
matplotlib.style.use("ggplot")


Using matplotlib backend: nbAgg

In [13]:
file_path = "/Users/szabolcs/dev/git/DAT210x/Module3/Datasets/"
file_name = "students.data"
df = pd.read_csv(file_path + file_name)
print(df.columns)
df.head()


Index(['id', 'sex', 'age', 'address', 'famsize', 'Pstatus', 'Medu', 'Fedu',
       'traveltime', 'studytime', 'failures', 'schoolsup', 'famsup', 'paid',
       'activities', 'nursery', 'higher', 'internet', 'romantic', 'famrel',
       'freetime', 'goout', 'Dalc', 'Walc', 'health', 'absences', 'G1', 'G2',
       'G3'],
      dtype='object')
Out[13]:
id sex age address famsize Pstatus Medu Fedu traveltime studytime ... famrel freetime goout Dalc Walc health absences G1 G2 G3
0 0 1 18 0 1 0 4 4 2 2 ... 4 3 4 1 1 3 4 0 11 11
1 1 1 17 0 1 1 1 1 1 2 ... 5 3 3 1 1 3 2 9 11 11
2 2 1 15 0 0 1 1 1 1 2 ... 4 3 2 2 3 3 6 12 13 12
3 3 1 15 0 1 1 4 2 1 3 ... 3 2 2 1 1 5 0 14 14 14
4 4 1 16 0 1 1 3 3 1 2 ... 4 3 2 1 2 5 0 11 13 13

5 rows × 29 columns


In [14]:
fig = plt.figure()
ax = fig.add_subplot(111, projection="3d")
ax.set_xlabel("Final Grade")
ax.set_ylabel("First Grade")
ax.set_zlabel("Daily Alcohol")

ax.scatter(df.G1, df.G3, df.Dalc, c="r", marker=".")
plt.show()



In [ ]: