Reputation: 1
IndexError Traceback (most recent call last)
in
----> 3 df[ii] = pd.read_csv('/content/CSVs/' + x[ii]).dropna()
ii = 0
df[ii] = pd.read_csv('/content/CSVs/' + x[ii]).dropna()
rf[ii] = RandomForestClassifier(random_state=0)
rf[ii].fit( df[ii].select_dtypes(exclude=['object']).replace((np.inf, -
np.inf, np.nan), 0) ,df[ii][' Label'])
f_i[ii] = list(zip(df[ii].columns,rf[ii].feature_importances_))
f_i[ii].sort(key = lambda x : x[1])
plt.barh([x[0] for x in f_i[ii][-20:]],[x[1] for x in f_i[ii][-20:]])
plt.show()
IndexError: list index out of range
This is the code, can someone please help me with this
Upvotes: 0
Views: 47