Pandas: reading Excel file starting from the row below that with a specific value

前端 未结 3 723
别那么骄傲
别那么骄傲 2021-01-12 21:41

Say I have the following Excel file:

    A      B     C
0   -      -     -
1   Start  -     -
2   3      2     4
3   7      8     4
4   11     2     17
         


        
3条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-12 21:58

    You could use pd.read_excel('C:\Users\MyFolder\MyFile.xlsx', sheetname='Sheet1') as it ignores empty excel cells.

    Your DataFrame should then look like this:

        A      B     C
    0   Start NaN   NaN
    1   3      2     4
    2   7      8     4
    3   11     2     17
    

    Then drop the first row by using

    df.drop([0])
    

    to get

        A      B     C
    0   3      2     4
    1   7      8     4
    2   11     2     17
    

提交回复
热议问题