File size: 931 Bytes
307d0dd
 
 
 
 
 
 
 
 
 
 
938c85e
307d0dd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
38
import os
import pandas as pd
import numpy as np
import csv
from abc import ABC, abstractmethod

class DataSet(ABC):
    '''
    Manage datasets of pollutants and meteorological data, in the format
    specified by KNMI.
    '''
    def __init__(self) -> None:
        self._dataframe = None

    def __getitem__(self, index:int):
        '''
        Allows its instances to use the [] (indexer) operators.
        '''
        if index not in range(0, len(self)):
            raise IndexError("Index out of bounds.")
        return self._dataframe.iloc[index]
    
    def __len__(self) -> int:
        '''
        Get the number of datapoints in the dataset.
        '''
        return len(self._dataframe)
    
    def get_df(self) -> pd.DataFrame:
        return self._dataframe

    @abstractmethod
    def _filter_data(self):
        '''
        Filters the dataset based on the variable(s) included.
        '''
        pass