Hey!
I’m getting this error " pandas._libs.hashtable.PyObjectHashTable.get_item
KeyError: ‘column’ " and unable to plot any chart, even I’m following Codecademy instructions.
Hey!
I’m getting this error " pandas._libs.hashtable.PyObjectHashTable.get_item
KeyError: ‘column’ " and unable to plot any chart, even I’m following Codecademy instructions.
That error suggests that there’s no column named “column” within your dataframe. Consider what columns are included in your csv
file and make sure you’re using a valid key.
Please could you also have a look at the following FAQ which describes the best way to set up a question for the forums (a more helpful title, a link to the lesson and a little categorisation makes it much easier for those trying to help out and anyone who was the same issue in the future).
you could also use the .columns
method to see the column names in a pandas df.
https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.columns.html
A KeyError means the key you gave pandas isn’t valid. Before doing anything with the data frame, use print(df.columns) to see what keys are available.
print(df.columns)
I was getting a similar kind of error in one of my codes. Turns out, that particular index was missing from my data frame as I had dropped the empty dataframe rows. If this is the case, you can do df.reset_index(inplace=True) and the error should be resolved.
Apparently, you just need to omit " " around column, so it should just be
for column in columns:
sns.countplot(df[column])
plt.show()
plt.clf()