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?
3 Answers
+ 2
Semi colons are not used in numpy
+ 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])
0
In other words, first 2 rows and first 5 columns of the numpy array.
Correct?