import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
# Creating a DataFrame with Name, Age, and City
data = {
"Name": ["Alice", "Bob", "Charlie", "David", "Eve"],
"Age": [25, 30, 35, 40, 28],
"City": ["New York", "Los Angeles", "Chicago", "Houston", "Phoenix"],
}
df = pd.DataFrame(data)
# Display the DataFrame
print("DataFrame:")
print(df)
# 1.1 Box Plot for Age
plt.figure(figsize=(8, 6))
sns.boxplot(x=df["Age"], color="skyblue")
plt.title("Box Plot of Age", fontsize=14)
plt.xlabel("Age", fontsize=12)
plt.show()
# Example Data for Heatmap
sales = [12000, 15000, 17000, 13000, 16000, 19000]
profit = [3000, 5000, 7000, 4000, 6000, 8000]
products_sold = [200, 250, 300, 220, 280, 310]
# Creating a DataFrame for the heatmap
heatmap_data = {
"Sales": sales,
"Profit": profit,
"Products Sold": products_sold,
}
df_heatmap = pd.DataFrame(heatmap_data)
# 1.2 Heatmap of Correlations
plt.figure(figsize=(8, 6))
correlation_matrix = df_heatmap.corr()
sns.heatmap(correlation_matrix, annot=True)
plt.title("Heatmap of Correlations", fontsize=14)
plt.show()
Comments