Skip to main content
Thirdwatchthirdwatch
health

Analyze FDA Recall Data With Python

Use pandas to compare recall classifications, product types, firms, causes, locations, and resolution timelines.

Jul 21, 2026 · 1 min read · 241 words
See the scraper →

Export JSON from the FDA Recalls Scraper and keep the source-shaped table unchanged. Analysis should happen in a copy so arrays, nulls, and identifiers remain available for audit.

import pandas as pd

df = pd.read_json("dataset_items.json")
df["report_date"] = pd.to_datetime(df["report_date"], errors="coerce")\ncounts = df.groupby(["product_type", "classification"]).size()\nopen_age = pd.Timestamp.today().normalize() - df["report_date"]
print(summary if "summary" in locals() else wide.head())

Audit before charting

First check duplicate product_type plus recall_number values, missing dates, null numeric values, and unexpected units. Print a few rows from every transformation. An attractive chart can still be wrong because an array was counted as text or a missing observation became zero.

Enforcement records change during an investigation. Refresh ongoing recalls and retain code_info and distribution_pattern. A company-name match alone is not enough to decide whether inventory is affected.

When exploding arrays, keep the original row count nearby. An exploded table counts relationships, not source records. When pivoting, verify that the proposed index is unique; otherwise pivot_table will aggregate duplicates without asking what they mean.

Make comparisons honest

Use explicit denominators and label the time period. For a monitoring dataset, separate newly collected records from older records modified during the window. For numeric series, compare compatible definitions and units. For categorical counts, include an "unknown" bucket rather than dropping missing values.

Save the notebook, Actor input, dataset ID, and collection timestamp together. That small bundle is enough to reproduce the result later, which matters more than adding another visualization.

Frequently asked questions

Does this Actor use an official data source?

Yes. It queries the publisher's official public API and returns normalized records with traceable identifiers and source links.

Can I schedule this workflow?

Yes. Save the validated input as an Apify Task, attach a schedule, and compare each successful dataset with the previous snapshot.

Related

Try it yourself

100 free credits, no credit card.

About 30 real searches. Add the MCP to Claude or Cursor in two minutes.