Henrike-Schwenn / Predicting_bike_rental_demand

My first ai project as part of my take on the amazing online course "Introduction to Machine Learning for Coders" taught by Jeremy Howard. I will be contributing to the Kaggle competition "Bike Sharing Demand", aiming to predict bike rental demand depending on the weather.
3 stars 0 forks source link

Update CsvObject #20

Closed Henrike-Schwenn closed 2 years ago

Henrike-Schwenn commented 3 years ago
Henrike-Schwenn commented 3 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
Henrike-Schwenn commented 3 years ago

https://pandas.pydata.org/docs/reference/api/pandas.read_csv.html?highlight=read_csv