Pandas file structure not supported error
I get NotImplementedError: file structure not yet supported
when I run the code below 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'))
Any idea on what might go wrong? The relevant query for a smaller sample of the same dataset is given below: Python pandas date parsing error while reading file
+3
source to share
2 answers
Thanks to @cosmoscalibur for detecting if your file is missing columns, one solution is to skip the header parsing:
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'))
this requires renaming one column from "3" to "PRCP" after loading:
df = df.rename(columns={3:'PRCP'})
+4
source to share