Files
vscode/extensions/copilot/test/simulation/fixtures/notebook/edits/data_visualization.ipynb
T
kieferrmandcopilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> 333d9a4053 Hello Copilot
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
2025-06-27 11:35:20 +02:00

2.8 KiB

Data Visualization Notebook

This notebook demonstrates how to visualize and analyze sales data using reusable functions.

In [ ]:
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns

Data Loading

In [ ]:
# Load sample sales data
data = pd.DataFrame({
    'month': ['Jan', 'Feb', 'Mar', 'Apr', 'May'],
    'sales': [200, 220, 250, 270, 300],
    'region': ['North', 'North', 'East', 'East', 'West']
})
data.head()

Visualization

In [ ]:
# Reusable function for plotting
def plot_sales(df, region=None):
    """
    Plot sales data.

    Args:
        df (pd.DataFrame): The input DataFrame containing sales data.
        region (str, optional): The region to filter data. Defaults to None.

    Returns:
        None
    """
    if region:
        df = df[df['region'] == region]

    plt.figure(figsize=(8, 5))
    sns.lineplot(data=df, x='month', y='sales', marker='o')
    plt.xlabel('Month')
    plt.ylabel('Sales')
    plt.show()

Plot sales for the North region

In [ ]:
plot_sales(data, region='North')

Plot sales for all regions

In [ ]:
plot_sales(data)