How To Solve Typeerror: List Indices Must Be Integers, Not List?
I am downloading data in json format and saving it into a data frame. data = [] for day in range(9,10): request=Request('https://api..../10/'+str(day)+'/'+appId='+appID+')
Solution 1:
Your data
is a list, as you define it at the start - data = []
- Hence when you trying to access them using another list column_names
, you get the error you are getting.
If you are trying to concatenate the different dataframes you get from the different requests, you should use pandas.concat
on data
to concatenate all the dataframes from the list into a single dataframe, before accessing its columns and using to_csv
on it. Example -
data[column_names].to_csv("data.csv")
Should be changed to -
pd.concat(data)[column_names].to_csv("data.csv")
Post a Comment for "How To Solve Typeerror: List Indices Must Be Integers, Not List?"