Pandas read in table without headers

How can I read in a .csv file (with no headers) and when I only want a subset of the columns (say 4th and 7th out of a total of 20 columns), using pandas? I cannot seem to be able to do usecols

In order to read a csv in that doesn't have a header and for only certain columns you need to pass params header=None and usecols=[3,6] for the 4th and 7th columns:

    df = pd.read_csv(file_path, header=None, usecols=[3,6])

See the docs

From: stackoverflow.com/q/29287224

Back to homepage or read more recommendations: