首页 > 其他分享 >pd.read_csv( parse_dates=True) AttributeError: 'DatetimeIndex' object has no attribute &

pd.read_csv( parse_dates=True) AttributeError: 'DatetimeIndex' object has no attribute &

时间:2024-01-21 10:33:07浏览次数:19  
标签:index dates DatetimeIndex weekofyear None csv True

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

相关文章

  • mybatisPlus注解fill = FieldFill.UPDATE和updateStrategy = FieldStrategy.IGNORED的
    由于当时使用mybatisPlus的updateById更新数据,习惯性的认为字段为null的不更新。但是上线后,出问题了。只更新状态字段,其他的一些属性竟然被置空了。赶紧排查,发现实体类中这些字段有fill=FieldFill.UPDATE,导致更新的时候如果这个字段为null也会更新为null。 同样作用的还有@T......
  • 使用 npm-check-updates 检查项目的 npm 依赖项是否有更新
    一、安装npm-check-updates:npminstall-gnpm-check-updates二、使用:在项目根目录运行以下命令,检查所有项目依赖项的最新版本:ncu执行结果如下:红色=主要升级青色=小幅升级绿色=补丁升级更新版本:ncu-u注意备份或者提交代码,确保包文件处于版本控制......
  • [PG] Function Candidates Selection Algorithm
    FunctionCandidatesSelectionAlgorithmenvironmentsetupInlightdborafceextension,executesqlbelow,CREATEDOMAINoracle.clobASTEXT;--version1CREATEFUNCTIONoracle.btrim(text,text)RETURNStextAS'btrim'LANGUAGEinternalSTRICT......
  • Lora升级!ReLoRa!最新论文 High-Rank Training Through Low-Rank Updates
    关注公众号TechLead,分享AI与云服务技术的全维度知识。作者拥有10+年互联网服务架构、AI产品研发经验、团队管理经验,同济本复旦硕,复旦机器人智能实验室成员,阿里云认证的资深架构师,项目管理专业人士,上亿营收AI产品研发负责人。摘要尽管通过扩展导致具有数千亿参数的大型网络在统......
  • Lora升级!ReLoRa!最新论文 High-Rank Training Through Low-Rank Updates
    关注公众号TechLead,分享AI与云服务技术的全维度知识。作者拥有10+年互联网服务架构、AI产品研发经验、团队管理经验,同济本复旦硕,复旦机器人智能实验室成员,阿里云认证的资深架构师,项目管理专业人士,上亿营收AI产品研发负责人。摘要尽管通过扩展导致具有数千亿参数的大型网络在......
  • [914] In Python's datetime library, you can format dates using the strftime() me
    InPython'sdatetimelibrary,youcanformatdatesusingthestrftime()method.Thismethodallowsyoutocreateaformattedstringrepresentationofadatetimeobject,specifyingtheformatyouwant.Here'showyoucanformatadateusingstrft......
  • Secure Code Warrior Introduction to OWASP Top 10 Awareness (with latest updates
    MissingFunctionAccessControlAccesstothesefunctionalitiesshouldberestrictedtoauthenticatedusers.However,thecurrentmechanismonlycheckswhetherauserexists.Anyuser,authenticatedornot,willbeabletoaccessrestrictedinformation.U......
  • Android官方资料--OTA Updates
    OTAUpdatesINTHISDOCUMENTAndroiddevicelayoutLifeofanOTAupdateMigratingfromPreviousReleasesAndroiddevicesinthefieldcanreceiveandinstallover-the-air(OTA)updatestothesystemandapplicationsoftware.Deviceshaveaspecialrecove......
  • Android官方资料--A/B System Updates
    A/BSystemUpdatesINTHISDOCUMENTOverviewBootloaderstateexamplesUpdateEnginefeaturesLifeofanA/BupdatePost-installstepImplementationKernelpatchesKernelcommandlineargumentsRecoveryBuildvariablesPartitionsFstabKernelslotargumentsOTApacka......
  • springboot加载bean失败:No matching autowired candidates found
    场景:之前在培训轮岗,一直没有干活,最近开始干活遇到xxljob,打算自己学习了解一下。在按照文档配置执行器项目时,发现怎么启动,xxlJobExecutor都没有被加载进来。解决:后来经过查阅,原来是springBoot启动默认扫描的是启动类所在的包以及其子包,而我的文件为:因此bean注入失败。把......