Skip to content

Bicycle Sales Database

👋 Welcome to your workspace! Here, you can run SQL queries, write Python code, and add text in Markdown. This workspace is automatically connected to a Microsoft SQL Server database containing two schemas (sales and production), which in turn have various details about the sales and inventory for bike stores (source).

You can click the "Browse tables" button in the upper righthand corner of the cell below to view the available tables for each schema.

There is a short query and a visualization of the number of bicycles in stock by year and category rendered in Plotly to get you started.

Spinner
DataFrameas
bicycle_sales
variable
SELECT *
from bicycle_sales
Run cancelled
# Import libraries
import pandas as pd
import plotly.express as px

# Create bar chart
fig = px.bar(
    bicycle_sales,
    x=bicycle_sales["model_year"].astype(str),
    y="total",
    color="category_name",
)

# Create labels and show plot
fig.update_layout(
    title="Bicycle Inventory<br><sup>By Quantity and Category of Product</sup>",
    title_x=0.5,
    xaxis_title="Year",
    yaxis_title="Quantity in Stock",
    legend_title="Bicycle Category",
    template="plotly_dark",
)
fig.show()

This is an interactive plot! Hover over different elements of the plot to explore the data!


💪 Now it's your turn to construct your own queries and analyze the data! Remember, you can review the tables in the database at any point using the "Browse tables" button.