0

Numpy array's colon usage

# new_record is the name of the numpy array new_record = np.array ([[188, 190, 189, 165, 180], [58, 62, 55, 68, 80]]) new_record.shape >>> (2, 5) heights_and_ages_arr[:2, :5 ] = new_record The meaning of a numpy array's colon seems to be a little different than that of a regular array's colon. Would it be correct to interpret the final line in the above code as selecting everything in row index up to but not including index 2, and from column index up to but not including index 5?

4th Sep 2020, 5:25 PM
Solus
Solus - avatar
3 Respuestas
+ 2
Semi colons are not used in numpy
4th Sep 2020, 7:25 PM
Namit Jain
Namit Jain - avatar
+ 1
Yes, because you sort of have a list of lists, the first "slice" is the array, then the next "slice" is how you would like to index said list print(new_record[0, 1:3]) print(new_record[1, 1:4])
4th Sep 2020, 5:40 PM
Steven M
Steven M - avatar
0
In other words, first 2 rows and first 5 columns of the numpy array. Correct?
4th Sep 2020, 5:28 PM
Solus
Solus - avatar