Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Data Science by (50.2k points)

Say I import the following excel spreadsheet into a df

Val1 Val2 Val3

1     2 3 

5     6 7 

9     1 2

How do I delete the column name row (in this case Val1, Val2, Val3) so that I can export a csv with no column names, just the data?

I have tried df.drop and df.ix[1:] and have not been successful with either.

1 Answer

0 votes
by (108k points)

 Just simply put header=False and for eliminating the index using index=False. 

CSV example with no header row, refer the code below:

df.to_csv('filename.csv', header=False)

TSV (tab-separated) example(omitting the index column), refer the code below:

df.to_csv('filename.tsv', sep='\t', index=False)

If you want to learn more about Pandas then visit this Python Course designed by industrial experts.

 

Related questions

Browse Categories

...