Fancy indexing with integer arrays
📖 Scenario: Imagine you have a list of daily temperatures for a week. You want to pick specific days to check the temperatures, but not in order. This is like picking favorite days to remember.
🎯 Goal: You will create a NumPy array of temperatures, then use fancy indexing with an integer array to select temperatures from specific days.
📋 What You'll Learn
Create a NumPy array called
temps with these exact values: [22, 19, 24, 21, 20, 23, 18]Create a NumPy array called
days with these exact indices: [0, 3, 5]Use fancy indexing with
days to select temperatures from temps and store in selected_tempsPrint the
selected_temps array💡 Why This Matters
🌍 Real World
Fancy indexing helps quickly pick specific data points from large datasets, like selecting certain days' temperatures from a weather dataset.
💼 Career
Data scientists often use fancy indexing to filter and analyze subsets of data efficiently without loops.
Progress0 / 4 steps