I am reading multiple CSV files which are quite large 4383 rows x 80 columns and merging them to create a large dataframe which I then use later on. For a few of these CSV files everything works fine, but as I increase the number I run into an error I don't understand.
import pandas as pd
import numpy as np
import datetime as dt
import cPickle as pickle
model_list = ["GDAY","SDVM","LPJX"]
#model_list = ["GDAY","SDVM"]
df_list = []
key_list = []
treatment = "AMB"
exp = "AVG"
for model in model_list:
df = pd.DataFrame(np.random.randn(4383, 80),
index=pd.date_range('20010101', periods=4383),
columns=['YEAR','DOY','CO2','PPT','PAR','AT','ST','VPD',\
'SW','NDEP','NEP','GPP','NPP','CEX','CVOC','RECO',\
'RAUTO','RLEAF','RWOOD','RROOT','RGROW','RHET',\
'RSOIL','ET','T','ES','EC','RO','DRAIN','LE',\
'SH','CL','CW','CCR','CFR','TNC','CFLIT',\
'CFLITA','CFLITB','CCLITB','CSOIL','GL',\
'GW','GCR','GR','CLLFALL','CRLIN','CWIN','LAI',\
'LMA','NCON','NCAN','NWOOD','NCR','NFR',\
'NSTOR','NLIT','NRLIT','NDW','NSOIL','NPOOLM',\
'NPOOLO','NFIX','NLITIN','NWLIN','NRLIN','NUP',\
'NGMIN','NMIN','NVOL','NLEACH','NGL','NGW',\
'NGCR','NGR','APARd','GCd','GAd','GBd','Betad'])
df_list.append(df)
# allows us to select by m, s or t
key_list.append((model,treatment,exp))
dfs = pd.concat(df_list, axis=1, keys=key_list,
names=["model","treatment","exp"])
dfs.to_pickle("models_output.pkl")
dfs = pd.read_pickle("models_output.pkl")
print dfs["GDAY","AMB","AVG"]
this will produce the error, but not when the loop over models is only two elements. How can I fix this?