How does this code work?

https://www.codecademy.com/paths/analyze-data-with-python/tracks/ida-3-introduction-to-numpy/modules/ida-3-1-numpy-syntax/lessons/numpy-introduction/exercises/review

import numpy as np

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

temperatures_fixed = temperatures + 3

print(temperatures_fixed)

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.

2 Likes

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