Spaces:
Sleeping
Sleeping
Download preprocessing/dataset.py from MLINPrediction/pollution_prediction: direct link, hf CLI and curl.
- Browser
- Download file 931 Bytes
-
https://huggingface.co/spaces/MLINPrediction/pollution_prediction/resolve/main/preprocessing/dataset.py
- Command line
-
hf download hf://spaces/MLINPrediction/pollution_prediction/preprocessing/dataset.py
-
curl -L -o dataset.py https://huggingface.co/spaces/MLINPrediction/pollution_prediction/resolve/main/preprocessing/dataset.py
931 Bytes
| 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 | |
| def _filter_data(self): | |
| ''' | |
| Filters the dataset based on the variable(s) included. | |
| ''' | |
| pass | |