How does this code work?

import numpy as np

temperatures = np.genfromtxt('temperature_data.csv', delimiter=',')

temperatures_fixed = temperatures + 3


monday_temperatures = temperatures_fixed[0,]

`thursday_friday_morning = temperatures_fixed[3:5,1]`

temperature_extremes = temperatures_fixed[(temperatures_fixed < 50) | (temperatures_fixed > 60)]

How does the red part work? Iā€™m still confused on indexing with 2-D arrays too :confused:

The subscript is two dimensional. The first value is a slice of the column, which is the second value. Column 1 is the index for 6:00. Thursday is row 3, but the colon means include to the end, so Friday is included.


This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.