1

The excel

  A      B      C   
1 apple  tometo grape
2 beer   wine   juice       

Reading by pandas, the first row will be the columns of DataFrame.

  apple  tometo grape
0 beer   wine   juice       

How can I read the excel like this:

  0      1      2
0 apple  tometo grape
1 beer   wine   juice       
Steve Hsu
  • 51
  • 1
  • 1
  • 8

2 Answers2

2

The file can be read using the file name as string or an open file object:

pd.read_excel('test.xlsx', index_col=0)

if you want to read particular sheet.

pd.read_excel(open('test.xlsx', 'rb'),sheet_name='Sheet3')

Index and header can be specified via the index_col and header arguments

pd.read_excel('test.xlsx', index_col=None, header=None)
Nick
  • 138,499
  • 22
  • 57
  • 95
Jay Kakadiya
  • 501
  • 1
  • 5
  • 12
1

First answer on google when you search for "pandas read excel file skip header": Pandas doc for method read_excel which has a skiprows argument to achieve what you like

Since your excel file has no header row, you should use header=None

Emrah Diril
  • 1,687
  • 1
  • 19
  • 27