0
0
NumPydata~15 mins

np.concatenate() for joining arrays in NumPy - Mini Project: Build & Apply

Choose your learning style9 modes available
Joining Arrays Using np.concatenate()
📖 Scenario: Imagine you have two lists of daily temperatures from two different cities. You want to combine these lists into one to analyze the overall temperature trend.
🎯 Goal: Learn how to use np.concatenate() to join two numpy arrays into one array.
📋 What You'll Learn
Create two numpy arrays with exact values
Create a variable to hold the combined array
Use np.concatenate() to join the arrays
Print the combined array
💡 Why This Matters
🌍 Real World
Joining arrays is useful when combining data from multiple sources, like merging temperature readings from different cities to analyze overall weather patterns.
💼 Career
Data scientists often need to combine datasets before analysis. Knowing how to join arrays efficiently is a key skill in data preparation.
Progress0 / 4 steps
1
Create two numpy arrays
Import numpy as np and create two numpy arrays called city1_temps and city2_temps with these exact values: [20, 22, 19] and [25, 24, 23] respectively.
NumPy
Need a hint?

Use np.array() to create numpy arrays from lists.

2
Create a variable for the combined array
Create a variable called combined_temps to hold the joined array.
NumPy
Need a hint?

Just create the variable first. You will assign the joined array in the next step.

3
Join the arrays using np.concatenate()
Use np.concatenate() with a list containing city1_temps and city2_temps to assign the joined array to combined_temps.
NumPy
Need a hint?

Pass a list of arrays to np.concatenate() to join them.

4
Print the combined array
Print the variable combined_temps to display the joined array.
NumPy
Need a hint?

Use print(combined_temps) to show the result.