impoer
Homework 1
NumPy
numpy.array():
This function creates a NumPy array from a list or other iterable, allowing you to perform vectorized operations on the data.
numpy.mean():
This function calculates the mean (average) of the elements in a NumPy array, which is useful for statistical analysis.
Pandas
pandas.read_csv():
This function reads data from a CSV file and creates a DataFrame, which is a tabular data structure. It's handy for loading and working with external data. ## pandas.groupby():
This function allows you to group data in a DataFrame based on one or more columns, enabling aggregation and summary statistics on grouped data.
Matplotlib
matplotlib.pyplot.plot():
This function is used to create line plots. You can specify the data points and customize the appearance of the plot with various parameters. ## matplotlib.pyplot.xlabel():
This function sets the label for the x-axis, which is essential for providing context to your plots and making them more informative.
Homework 2: API Research
I researched the SpaceX API (https://api.spacexdata.com/v4/). One unique aspect I found in the documentation is the extensive information it provides about SpaceX’s missions, rockets, launches, and more. It’s a RESTful API that allows users to access a wealth of data related to SpaceX’s activities, including historical and real-time data.
Scenario: Imagine you are building a SpaceX mission tracker application. You can use the SpaceX API to fetch information about upcoming launches, launch details, rocket specifications, and mission outcomes. Users can search for specific missions, view launch schedules, and get notifications about upcoming launches. This app could provide space enthusiasts with up-to-date information about SpaceX missions and their outcomes.
import pandas as pd # Importing the Pandas library for data manipulation
# Create a DataFrame with sample data
data = {'Name': ['Alice', 'Bob', 'Charlie'],
'Age': [25, 30, 22]}
df = pd.DataFrame(data)
# Using a prefixed function
mean_age = df['Age'].mean() # Calculate the mean age
print("Mean Age:", mean_age)
# Using a prefixed variable
num_rows = df.shape[0] # Get the number of rows in the DataFrame
print("Number of Rows:", num_rows)
In this example, we imported the Pandas library, created a DataFrame, and used the prefixed function df[‘Age’].mean() to calculate the mean age and the prefixed variable df.shape[0] to get the number of rows in the DataFrame.