Exclude first row when importing data from excel into Python

Nguyen picture Nguyen · Aug 26, 2017 · Viewed 24.4k times · Source

I have a partial code to import excel into Python as strings. How I can exclude first row when importing data from excel into Python?

import pandas as pd
data = pd.read_excel(".xlsx", parse_cols="A,C,E,G, I, K, M, O, Q, S, U, W, Y, AA, AC, AE, AG, AI, AK, AM, AO, AQ, AS, AU, AW, AY, BA, BC, BE, BG, BI, BK, BM, BO, BQ, BS, BU, BW, BY, CA, CC, CE, CG, CI, CK, CM, CO, CQ, CS, CU, CW, CY, DA, DC, DE, DG, DI, DK, DM, DO, DQ, DS, DU, DW, DY, EA, EC, DE, EG, EI, EK, EM, EO, EQ, ES, EU, EW, EY")
data = data.to_string()

Answer

Onel Harrison picture Onel Harrison · Aug 26, 2017

The pandas documentation for the pd.read_excel method mentions a skiprows parameter that you can use exclude the first row of your excel file.

Example

import pandas as pd
data = pd.read_excel("file.xlsx", parse_cols="A,C,E,G", skiprows=[0])

Source: pandas docs