Closed Henrike-Schwenn closed 2 years ago
09.07.21 50 min
https://pythonbasics.org/constructor/
Don't define methods in a constructor. Set them as self.method() and define them afterwards.
class Plane:
def __init__(self):
self.wings = 2
# fly
self.drive()
self.flaps()
self.wheels()
def drive(self):
print('Accelerating')
def flaps(self):
print('Changing flaps')
def wheels(self):
print('Closing wheels')
class CsvObject:
def __init__(self, pathCsvDataset="Directory leading to a csv file", csvDataset="Csv file to be read", csvDataframe="Name of Dataframe"):
self.pathCsvDataset = pathCsvDataset
self.csvDataset = csvDataset
self.csvDataframe = csvDataframe
self.CreateDataframe()
def CreateDataframe(self):
os.chdir(self.pathCsvDataset)
#TODO: Verify data format csv
return self.csvDataframe == pandas.read_csv(self.csvDataset)
Works
TrainingSet.CreateDataframe()
datetime season holiday ... casual registered count
0 False False False ... False False False
1 False False False ... False False False
2 False False False ... False False False
3 False False False ... False False False
4 False False False ... False False False