def load_data(dataset):
"""Load data from a given dataset
Parameters
----------
dataset : str
Searches from dataset.h5 in this file's directory
Returns
-------
DataFrame
Hourly temperature data
"""
p = Path(os.path.dirname(os.path.realpath(__file__))) / 'data'
fname = p / f'{dataset}.h5'
try:
return pd.read_hdf(str(fname))
except FileNotFoundError:
sources = {f.stem for f in p.iterdir() if
f.is_file() and f.name.endswith('h5')}
raise RuntimeError(f"Could not not find {dataset!r}. Existing "
f"datasets are {sources}")
评论列表
文章目录