pandas读取文件的read_csv()方法的parse_dates,index_col参数介绍
pd.read_csv( parse_dates=True)
data = pd.read_csv(f'datasets/{name}.csv', index_col='date', parse_dates=True)
dt.weekofyear.to_numpy(),
df_asset[“week_of_year”] = df_asset.index.weekofyear
Arguments: Namespace(alpha=0.0005, archive='forecast_csv', batch_size=8, dataset='ETTh1', epochs=None, eval=True, gpu=0, iters=None, kernels=[1, 2, 4, 8, 16, 32, 64, 128], lr=0.001, max_threads=None, max_train_length=3000, repr_dims=160, run_name='run_001', save_every=None, seed=None)
Traceback (most recent call last):
File "train.py", line 55, in <module>
data, train_slice, valid_slice, test_slice, scaler, pred_lens, n_covariate_cols = datautils.load_forecast_csv(args.dataset)
File "F:\software\CoST-main\datautils.py", line 35, in load_forecast_csv
dt_embed = _get_time_features(data.index)
File "F:\software\CoST-main\datautils.py", line 30, in _get_time_features
dt.weekofyear.to_numpy(),
AttributeError: 'DatetimeIndex' object has no attribute 'weekofyear'
原因分析:
pandas 1.1.0 版后已移除.
一年中的星期和星期已被弃用。请改用Datetimelndex.isocalendar().Week。
解决方案:
改成这样:
df_asset[“week_of_year”] = df_asset.index.isocalendar().week ### pandas 1.1.0 版后已移除.index.weekofyear.
————————————————
链接:https://blog.csdn.net/weixin_45196794/article/details/134172075
(nbeatsx_epf) [root@ibiomed CoST-main]# conda list | grep pandas
pandas 0.25.2 py37he6710b0_0 anaconda
标签:index,dates,DatetimeIndex,weekofyear,None,csv,True From: https://www.cnblogs.com/emanlee/p/17977568