pandas 文件结构不支持错误 [英] Pandas file structure not supported error

查看:70
本文介绍了 pandas 文件结构不支持错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在此NotImplementedError: file structure not yet supported. >文件

I get a NotImplementedError: file structure not yet supportedwhen I run the code below on this file

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'))

关于可能出什么问题的任何想法?在此相同数据集的较小样本上的相关查询在这里: 读取时Python熊猫中的日期解析错误文件

Any idea on what might be going wrong? Related query on a smaller sample of this same dataset is here: Date parse error in Python pandas while reading file

推荐答案

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

Thanks to @cosmoscalibur for spotting that your file is missing columns, one solution is to skip parsing the header:

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":

this will require you to rename the single column from '3' to 'PRCP' after loading:

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

这篇关于 pandas 文件结构不支持错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆