Reputation: 23
I've received an error after trying to remove a column from my dataframe. KeyError: "['column name'] not found in axis" Advice is to put axis=1, but I did that and I still receive the same error. I don't know, what the problem is.
for i in range(1,len(file_list)):
data = pd.read_table(file_list[i], encoding='unicode_escape')
df = pd.DataFrame(data)
main_dataframe = pd.concat([main_dataframe, df], axis = 1)
main_dataframe = main_dataframe.drop('column name',axis=1)
Upvotes: 0
Views: 335
Reputation: 1248
"column name" is a placeholder for your actual column name. For example, if you want to delete a column named "Surname", use:
df = df.drop("Surname",axis=1)
The error you have here is clearly stating that there is no column named "column name" in your dataframe.
Upvotes: 1