UnboundLocalError: local variable 'df' referenced before assignment
romanme2 opened this issue · comments
Hi,
I am getting the following error below for the code below. Could you please assist? I am trying to pull the wells drilled from the monthly-energy review
Error: UnboundLocalError: local variable 'df' referenced before assignment
list = ['PATWPUS']
df = eia.get_series_via_route(
route="total-energy",
facet='msn',
series="PATWPUS",
frequency="monthly"
)
df= df.apply(lambda x: x.astype(float) if x.dtype == 'object' else x)
df['Vintage']= vintage
df['Type']= "Crude"
crude = df.copy()
crude
I have updated the code in 0.3.6 so you can use your facet 'msn'. So, this should work.
Regarding your error I have encountered a JSONDecodeError in my tests with the incoming data as I'm getting back incomplete json data and then the parsing doesn't work any more.
It seems when the dataset is too large it cuts off the remaining data, when I limit my request with a start_date all seems fine.
Not sure exactly what's going on. Weirdly enough when I just paste the url from the API request asking for the full dataset in my browser I get all the data, but using requests it cuts it off.
I will have a look again at it in the coming days maybe this issue will solve itself.
Awesome, glad it helps you