11-LSTM多变量-LSTM数据预处理_tmp
import pandas as pd
import datetime
# 加载数据
def parser(x):
return datetime.datetime.strptime(x, '%Y %m %d %H')
dataset = pd.read_csv('../LSTM系列/LSTM多变量3/data_set/raw.csv',
parse_dates=[['year', 'month', 'day', 'hour']], index_col=0, date_parser=parser)
dataset.drop('No', axis=1, inplace=True)
# 自定义列名
dataset.columns = ['pollution', 'dew', 'temp', 'press', 'wnd_dir', 'wnd_spd', 'snow', 'rain']
dataset.index.name = 'date'
dataset['pollution'].fillna(0, inplace=True)
dataset = dataset[24:] # 删除前24小时