Extracting specific columns in numpy array

前端 未结 9 1308
隐瞒了意图╮
隐瞒了意图╮ 2020-11-28 02:27

This is an easy question but say I have an MxN matrix. All I want to do is extract specific columns and store them in another numpy array but I get invalid syntax errors. He

9条回答
  •  天命终不由人
    2020-11-28 02:58

    I think the solution here is not working with an update of the python version anymore, one way to do it with a new python function for it is:

    extracted_data = data[['Column Name1','Column Name2']].to_numpy()
    

    which gives you the desired outcome.

    The documentation you can find here: https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.to_numpy.html#pandas.DataFrame.to_numpy

提交回复
热议问题