0
0
Data Analysis Pythondata~30 mins

Array creation (array, arange, linspace) in Data Analysis Python - Mini Project: Build & Apply

Choose your learning style9 modes available
Array Creation with NumPy
📖 Scenario: You are working as a data analyst. You need to create different types of number arrays to analyze sales data over time.
🎯 Goal: Learn how to create arrays using array, arange, and linspace from the NumPy library.
📋 What You'll Learn
Use NumPy to create arrays
Create an array from a list
Create an array with evenly spaced values using arange
Create an array with a specific number of points using linspace
💡 Why This Matters
🌍 Real World
Creating arrays is a basic step in data analysis for organizing and manipulating numerical data like sales, time, or measurements.
💼 Career
Data analysts and scientists use array creation to prepare data for calculations, statistics, and visualizations.
Progress0 / 4 steps
1
Create a NumPy array from a list
Import the NumPy library as np. Then create a NumPy array called sales from the list [100, 200, 300, 400, 500].
Data Analysis Python
Need a hint?

Use np.array() to convert a list to a NumPy array.

2
Create an array with arange
Create a NumPy array called days using np.arange that contains integers from 1 to 7 inclusive.
Data Analysis Python
Need a hint?

Remember that np.arange(start, stop) includes start but excludes stop.

3
Create an array with linspace
Create a NumPy array called time_points using np.linspace that contains 5 evenly spaced numbers between 0 and 10 inclusive.
Data Analysis Python
Need a hint?

np.linspace(start, stop, num) creates num points evenly spaced between start and stop, including both ends.

4
Print all arrays
Print the arrays sales, days, and time_points each on a separate line.
Data Analysis Python
Need a hint?

Use three separate print() statements to show each array.