Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # https://www.rasgoml.com/feature-engineering-tutorials/how-to-create-time-series-features-with-tsfresh
- import pandas as pd
- import tsfresh
- from urllib.request import urlopen
- from io import BytesIO
- from zipfile import ZipFile
- url = "https://archive.ics.uci.edu/ml/machine-learning-databases/00501/PRSA2017_Data_20130301-20170228.zip"
- r = urlopen(url)
- zf = ZipFile(BytesIO(r.read()))
- df = pd.DataFrame()
- for file in zf.infolist():
- if file.filename.endswith('.csv'):
- df = df.append(pd.read_csv(zf.open(file)))
- df['timestamp'] = pd.to_datetime(df[["year", "month", "day", "hour"]])
- df.drop(columns=['No'], inplace=True)
- df.sort_values(by=['timestamp', 'station']).head(10)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement