0% found this document useful (0 votes)
3 views3 pages

Data Visualization Using MATPLOTLIB

The document provides a comprehensive guide on data visualization using both Matplotlib and Seaborn libraries in Python. It includes various visualizations such as age distribution, purchase amount distribution, gender count, product category distribution, payment method usage, and a correlation heatmap. Each section utilizes different plotting techniques to analyze and present data from a dataset.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views3 pages

Data Visualization Using MATPLOTLIB

The document provides a comprehensive guide on data visualization using both Matplotlib and Seaborn libraries in Python. It includes various visualizations such as age distribution, purchase amount distribution, gender count, product category distribution, payment method usage, and a correlation heatmap. Each section utilizes different plotting techniques to analyze and present data from a dataset.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Data Visualization using MATPLOTLIB

import pandas as pd
import [Link] as plt

# Load dataset
df = pd.read_csv("[Link]")

# 1. Age Distribution
[Link]()
[Link](df['age'], bins=15)
[Link]("Age Distribution")
[Link]("Age")
[Link]("Frequency")
[Link]()

# 2. Purchase Amount Distribution


[Link]()
[Link](df['purchase_amount_usd'], bins=15)
[Link]("Purchase Amount Distribution")
[Link]("Purchase Amount (USD)")
[Link]("Frequency")
[Link]()

# 3. Gender Count
[Link]()
df['gender'].value_counts().plot(kind='bar')
[Link]("Gender Distribution")
[Link]("Gender")
[Link]("Count")
[Link]()

# 4. Product Category Distribution


[Link]()
df['product_category'].value_counts().plot(kind='bar')
[Link]("Product Category Distribution")
[Link]("Product Category")
[Link]("Count")
[Link](rotation=45)
[Link]()

# 5. Payment Method Distribution


[Link]()
df['payment_method'].value_counts().plot(kind='bar')
[Link]("Payment Method Usage")
[Link]("Payment Method")
[Link]("Count")
[Link]()

# 6. Income vs Purchase Scatter Plot


[Link]()
[Link](df['monthly_income_usd'], df['purchase_amount_usd'])
[Link]("Income vs Purchase Amount")
[Link]("Monthly Income (USD)")
[Link]("Purchase Amount (USD)")
[Link]()

Data Visualization using Seaborn

import pandas as pd
import seaborn as sns
import [Link] as plt

# Load dataset
df = pd.read_csv("[Link]")

sns.set_style("whitegrid")

# 1. Age Distribution
[Link]()
[Link](df['age'], bins=15, kde=True)
[Link]("Age Distribution")
[Link]()

# 2. Purchase Amount Distribution


[Link]()
[Link](df['purchase_amount_usd'], bins=15, kde=True)
[Link]("Purchase Amount Distribution")
[Link]()

# 3. Gender Count
[Link]()
[Link](x='gender', data=df)
[Link]("Gender Distribution")
[Link]()

# 4. Product Category Count


[Link]()
[Link](x='product_category', data=df)
[Link](rotation=45)
[Link]("Product Category Distribution")
[Link]()

# 5. Payment Method Count


[Link]()
[Link](x='payment_method', data=df)
[Link]("Payment Method Distribution")
[Link]()

# 6. Income vs Purchase Scatter


[Link]()
[Link](x='monthly_income_usd', y='purchase_amount_usd', data=df)
[Link]("Income vs Purchase Amount")
[Link]()

# 7. Satisfaction Score Distribution


[Link]()
[Link](x='customer_satisfaction_score', data=df)
[Link]("Customer Satisfaction Score Distribution")
[Link]()

# 8. Correlation Heatmap
[Link]()
corr = [Link](numeric_only=True)
[Link](corr, annot=True)
[Link]("Correlation Matrix")
[Link]()

You might also like