In this exercise, you will extract specific columns from the dataset to create a subset and verify the number of rows. This helps in focusing on relevant data for analysis.
Create a Subset:
Select the following columns from the DataFrame:
Customer ID
Age
Location
Purchase Amount (USD)
Review Rating
Use the head() function to display the first few rows of the subset.
Verify the Number of Rows:
Use the shape attribute to get the number of rows.
Print the row count.
Python Code:
# 1. Create a subset with selected columns
import pandas as pd
subset = df[['Customer ID', 'Age', 'Location', 'Purchase Amount (USD)', 'Review Rating']]
Subset.head(4)
#2. Check the number of rows in the subset:
import pandas as pd
row_count = subset.shape[0]
print("Number of Rows in Subset:", row_count)