Matt
Matt

Reputation: 3557

Format of numpy arrays

This is a pretty easy question, I was wondering how to decipher this array:

model[Best[i][j]][6]

Is it recreating another array based off of the 'Best' array within the brackets? I'm not sure how to translate this to myself.

Upvotes: 1

Views: 47

Answers (1)

dkar
dkar

Reputation: 2123

If we are talking about numpy arrays, this will return the value of array model positioned at Best[i][j] (this should be a number perhaps from another array) row and 6th column. Here is an example:

import numpy as np
model = np.array([[1,2],[3,4]])
Best  = np.array([[0,0],[1,1]])

i = 0   # Best[i][j] is 0
j = 1

print model[Best[i][j]][1] # It prints model[0][1], which is 2

Upvotes: 2

Related Questions