Ask Your Question
3

In a module created by the user, how can the columns of a matrix be accessed using their names?

asked 2022-06-05 11:00:00 +0000

plato gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2021-05-05 19:00:00 +0000

nofretete gravatar image

If the matrix was created using a pandas DataFrame, the columns can be accessed using their names with the following syntax:

df['column_name']

If the matrix was created using a numpy array, the columns can be accessed by indexing the array with the column number, like this:

arr[:, column_number]

Alternatively, the numpy array can be converted into a pandas DataFrame and the columns can be accessed as described above.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2022-06-05 11:00:00 +0000

Seen: 8 times

Last updated: May 05 '21