liveBook · Manning

Descriptive statistics

As explained in Starting Data Analytics with Generative AI and Python

Descriptive analytics is the examination and summarization of observed data to characterize its distributions, patterns, and relationships.

Which products sell most, and where do orders get stuck? Descriptive statistics summarize observed data so you can see its typical values, variation, and unusual cases. They are part of descriptive analytics: the broader work of examining business performance through summaries, comparisons, and charts. They describe what the records show; they do not, by themselves, explain why a pattern occurred. section 3.3 section 3.3.4

Start with the data you have, then choose summaries that fit the question:

  • Inspect a pandas DataFrame with head(), info(), and describe() to check its columns, non-null counts, data types, and numerical summaries. Use value_counts() for category frequencies. Some checks overlap, so choose what makes your inspection clear rather than running every command mechanically. section 2.3
  • After preparing the relevant records, summarize variables such as revenue or review scores. Means, medians, modes, standard deviations, and percentiles offer different views of the data; charts help make patterns visible. section 3.2 section 3.3
  • Compare groups that matter to the decision—such as regions, product categories, or sellers—using counts, cross-tabulations, and visualizations. section 3.1 section 3.2

Where are orders getting stuck?

To compare order statuses by product category, merge the relevant order, item, and product records; group by status and category; and count the records. A table with thousands of rows is hard to scan, so ask an AI assistant which visualization would help. A stacked bar chart can show status counts across categories. Then inspect the underlying results: orders marked approved but apparently never shipped are a lead for investigation, not proof of what caused the delay. A later regression analysis can address a different question about delivery times. section 3.3.4

import pandas as pd
import matplotlib.pyplot as plt

# Pivot the DataFrame for the stacked bar chart
status_pivot = 
status_distribution_sorted.pivot_table(
index='product_category_name_english',
    columns='order_status',
    values='count',
    aggfunc='sum',
    fill_value=0)

# Plot the stacked bar chart
plt.figure(figsize=(20, 10))
status_pivot.plot(kind='bar', stacked=True, figsize=(20, 10))

plt.xticks(rotation=90, fontsize=10)
plt.yticks(fontsize=12)
plt.xlabel('Product Category', fontsize=12)
plt.ylabel('Count of Orders', fontsize=12)
plt.title('Order Status Distribution by Product Category', fontsize=14)
plt.legend(title='Order Status', title_fontsize=12, fontsize=10, 
loc='upper right')

plt.tight_layout()
plt.show()

This pandas and Matplotlib workflow pivots grouped status counts and plots a stacked bar chart by product category. Check that the displayed counts answer your question before interpreting the picture. section 3.3.4

Treat AI-generated questions and code as proposals to test. Confirm that the data has been cleaned and joined for the intended comparison, run the code, and look back at the resulting records when something seems surprising. Descriptive findings can guide business decisions and identify questions worth more advanced analysis, but a useful protocol leaves room to revise the plan as the data reveals new issues. section 3.0 section 3.2 section 3.3.4

How Starting Data Analytics with Generative AI and Python covers it

How deep it goes
Works through inspection, summary measures, grouping, and visualization; defers regression-based delivery-time analysis.
Examples
Uses restaurant ordering decisions and e-commerce order-status counts by product category, including a stacked bar chart.
What it assumes
Assumes imported pandas DataFrames and an initial understanding of data meaning; develops first-pass inspection before further analysis.
What you can do after
Apply it via pandas and Matplotlib to summarize order statuses, compare categories, and investigate suspicious results.
How it connects
Connects data quality, research questions, visualization, and statistical inference in an iterative analysis workflow.

Also explained in

Compare how 6 books explain descriptive statistics →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Starting Data Analytics with Generative AI and Python. The section links point to the parts of the book it draws on.