I have a dataframe called 'data' with 55 columns and I want to create a new csv file with the first 52 columns. The last three column names I do not want to include are 'Class', 'part_id' and 'image_file'. I have been searching and the solution is something like this:
import pandas as pd
useful_columns = [col1,col2,...] #list the columns I need
data[useful_columns].to_csv('new.csv', index=False) #prevent creating extra column
#reference: https://stackoverflow.com/questions/46546388/how-to-skip-columns-of-csv-file
I get an error that says 'col1, col2 not defined' but I do have 52 columns that I want to export to a new csv file, it is so long to write each column name (Particle ID, Area(ABD), Aspect Ratio...etc). Is there a fast way to say "just take the first 52 columns from the existing dataframe and put them into a new csv file?
Thanks so much in advance!