How to drop the first column in pandas when read a csv code example
Example 1: drop first column read_csv
# Read column names from file
cols = list(pd.read_csv("sample_data.csv", nrows =1))
print(cols)
# Use list comprehension to remove the unwanted column in **usecol**
df= pd.read_csv("sample_data.csv", usecols =[i for i in cols if i != 'name'])
Example 2: drop the first column pandas
df.set_index['column'] # column refers to column to be set as index