[Python] numpy.loadtxt: load a range of columns

Discussão em 'Python' iniciado por Stack, Julho 28, 2025.

  1. Stack

    Stack Membro Participativo

    I have a .csv file with both string and integer - containing columns. I need to use numpy.loadtxt method to import the matrix formed from the specified columns. How can I do that? Right now I am trying to do the following:

    data = np.loadtxt(open(path_to_data, "rb"), delimiter=",", skiprows=1, usecols=[1:])


    Basically trying to read all columns but first, but it is giving an error:


    SyntaxError: invalid syntax
    ​

    Because such syntax is not allowed: usecols=[1:]

    Continue reading...

Compartilhe esta Página