gpt4 book ai didi

python - 未实现错误 : file structure not yet supported from pandas read_csv

转载 作者:太空宇宙 更新时间:2023-11-03 14:19:20 24 4
gpt4 key购买 nike

当我在此 file 上运行下面的代码时,我得到一个 NotImplementedError: file structure not yet supported

import constants, pandas, pdb
from datetime import datetime, timedelta

df = pandas.read_csv('300113R1.DNC', skiprows = 11, delim_whitespace=True,usecols=['Y','M','D','PRCP'],
parse_dates={"datetime": [0,1,2]}, index_col="datetime",
date_parser=lambda x: pandas.datetime.strptime(x, '%Y %m %d'))

知道可能出了什么问题吗?关于同一数据集的较小样本的相关查询在这里: Date parse error in Python pandas while reading file

最佳答案

感谢@cosmoscalibur 发现您的文件缺少列,一种解决方案是跳过解析标题:

df = pandas.read_csv('300113R1.DNC', skiprows = 12, delim_whitespace=True,usecols=[0,1,2,3], header=None
parse_dates={"datetime": [0,1,2]}, index_col="datetime",
date_parser=lambda x: pandas.datetime.strptime(x, '%Y %m %d'))

这将要求您在加载后将单列从“3”重命名为“PRCP”:

df = df.rename(columns={3:'PRCP'})

关于python - 未实现错误 : file structure not yet supported from pandas read_csv,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29806330/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com