0

The purpose of my code is to delete a column that doesn't have a header, which Python calls "Unamed 12". In the print df command you can see that the column is dropped but when I look at my file it is still there. How can I get the code to drop the column form the file?

Import pandas as pd
df = pd.read_csv('Test.csv')
df.drop (['Unamed: 12'], axis = 1, inplace = True
print (df)
JacobElliott
  • 127
  • 1
  • 1
  • 8
  • Check the spelling of the column, in most case it is 'Unnamed: 12' – Vaishali Aug 28 '17 at 19:12
  • "Unamed 12" != "Unamed: 12", and as @Vaishali both misspell the word "unnamed" (two Ns). Your code is also missing a right parenthesis, so it wouldn't run in the first place. – user94559 Aug 28 '17 at 19:14
  • you're loading the csv into a pandas dataframe. If you want to change the csv you have to write the updated dataframe back into the csv. `df.to_csv(...)` – Alter Aug 28 '17 at 19:14
  • Second answer in that dupe solves your problem. If not, please edit your question to provide more detail, input, and desired output. No one can help you like this. The code you've pasted here isn't even capable of running. – cs95 Aug 28 '17 at 19:25

0 Answers0