Practical Exercises: Sales Data Analysis
After diving deep into our case study on Sales Data Analysis, it's time for some hands-on practice. Below are practical exercises that complement the material we've covered. Remember, the best way to solidify your understanding is through application!
Exercise 1: Data Exploration
- Load the 'sales_data.csv' file into a DataFrame.
- Display the first 5 rows of the DataFrame.
- Provide basic statistics for each numeric column.
Solution
import pandas as pd
# Load the data
df = pd.read_csv('sales_data.csv')
# Display the first 5 rows
print(df.head())
# Basic statistics
print(df.describe())
Exercise 2: Data Visualization
- Create a bar chart showing the total revenue generated by each product.
- Create a pie chart representing the percentage of total sales for each product.
Solution
import matplotlib.pyplot as plt
# Bar chart
df_grouped = df.groupby('Product_Name')['Revenue&apos...