blob: 650d33409f88cee59506d523d5a57066484c21f5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
import pandas as pd
class Dataset:
def __init__(self, path):
self.path = path
try:
self.df = pd.read_csv(path)
except FileNotFoundError:
raise "Couldn't find dataset at: {}".format(path)
self.df.drop(columns=['Index'], inplace=True)
self.df.dropna(inplace=True)
self.df.columns = self.df.columns.str.lower()
self.df.columns = self.df.columns.str.replace(' ', '_')
self.df.rename(columns={'hogwarts_house': 'house'}, inplace=True)
@property
def df_scores(self):
return self.df.loc[:, 'arithmancy':'flying']
|