Skipping range of rows after header through pandas.read_excel

前端 未结 1 1867
南笙
南笙 2021-02-20 10:15

I know the argument usecols in pandas.read_excel() allows you to select specific columns.

Say I read an Excel file in with pandas.read_ex

1条回答
  •  南笙
    南笙 (楼主)
    2021-02-20 10:55

    As per the documentation for pandas.read_excel, skiprows must be list-like.

    Try this instead to exclude rows 1 to 336 inclusive:

    df = pd.read_excel("file.xlsx",
                       sheet_name = "Sheet1",
                       skiprows = range(1, 337),
                       usecols = "H:BD")
    

    Note: range constructor is considered list-like for this purpose, so no explicit list conversion is necessary.

    0 讨论(0)
提交回复
热议问题