The sentence above your chart says “reader sentiment”. The collection input says reviewRatingMin.

That small mismatch is worth catching before publication. The notebook can calculate a perfectly correct mean for a population your headline never names.

The Actor combines review ordering, language restrictions, rating thresholds, spoiler exclusion and collection caps. A capped selection of recent English reviews above a rating floor measures that conditional subset, not general reader sentiment.

The arithmetic isn't the embarrassing part. The subject of the sentence is.

Whose ratings reach your chart?

“Reader sentiment” suggests a broad population. Your observations start with public reviews attached to selected books. Readers who never publish a review are already outside that frame.

Dataspryva's review Actor makes the remaining selection choices explicit. Keep them beside the analysis, where an edit to the chart can't detach the number from its conditions.

Example input: this records the collection rules in a manifest before fetching anything.

import os import duckdb import pandas as pd from apify_client import ApifyClient run_input = { "mode": "reviews", "bookUrls": ["4671"], "maxItems": 1000, "maxReviewsPerBook": 100, "reviewSort": "NEWEST", "reviewLanguage": "en", "reviewRatingMin": 4, "excludeSpoilers": True, } manifest = { "label": "selected", "selection": {**run_input, "bookUrls": list(run_input["bookUrls"])}, "defaults": {"maxReviewsPerBook": 30, "maxItems": 50}, } 

A screenshot of a mean can't recover these settings. The manifest preserves the sampling frame, including decisions that may have looked like harmless cleanup.

The star filter selects the outcome

For an average of ratings, a minimum star threshold filters the outcome you're trying to describe.

Lower-rated reviews can't contribute. Their absence isn't evidence that readers rarely disliked the book.

The controls impose different boundaries:

Selection rule What falls outside the frame Consequence for interpretation
bookUrls Books outside your supplied selection More reviews cannot repair selective book coverage
reviewLanguage Reviews outside the requested language A linguistic restriction, without establishing reviewers' countries
reviewRatingMin and reviewRatingMax Ratings outside the permitted interval An average conditional on passing an outcome filter
excludeSpoilers Reviews marked as containing spoilers A content-based exclusion whose relationship with ratings is unknown
reviewSort with a cap Reviews beyond the collected portion of the ordering An ordered slice rather than a random sample

This is the gap between the intended subject and the available evidence:

Readers of the selected books ↓ publish a public review ↓ pass language, rating and spoiler conditions ↓ fall within ordering and collection limits ↓ supply a usable rating Reviews contributing to the reported mean 

Spoiler marking could relate to engagement, plot discussion or reading completion. Those are hypotheses about selection, not measured characteristics of the excluded group.

Its exclusion has no established direction of effect on the average.

Newest first isn't a reporting period

A fixed review allowance can span a short interval for a frequently reviewed book and a much longer interval for another. The other restrictions can change that coverage again.

Calling the comparison “current sentiment” could therefore compare different historical windows.

There's also a shared ceiling: maxItems counts every emitted record across the run. With multiple books, it can stop collection before every book reaches its own allowance. The returned rows don't establish how that shortfall was distributed.

This cell fetches the records and retains the collection identity.

client = ApifyClient(os.environ["APIFY_TOKEN"]) run = client.actor( "dataspryva/goodreads-book-author-and-listopia-list-scraper" ).call(run_input=run_input) manifest["run_status"] = run["status"] manifest["dataset_id"] = run["defaultDatasetId"] if run["status"] != "SUCCEEDED": raise RuntimeError(f"Collection ended with status {run['status']}") items = list( client.dataset(run["defaultDatasetId"]).iterate_items() ) 

A successful run isn't a coverage certificate. Reaching a cap flags possible truncation; falling below it doesn't prove exhaustive retrieval.

Audit the denominator before calculating it

The Actor omits empty fields. An absent spoiler value isn't an explicit false, and an omitted rating must not become zero.

For this calculation, retain uniquely identified reviews with a book identity. Preserve unusable ratings and dates as missing, and count them separately: the average and the observed time window can have different denominators.

This function parses numeric strings and timestamps, records exclusions, and removes repeated identities within each book.

def prepare_reviews(records): columns = [ "recordType", "reviewId", "bookId", "rating", "createdAt", "spoiler", ] frame = pd.DataFrame(records).reindex(columns=columns) frame = frame.loc[frame["recordType"].eq("review")].copy() for column in ("reviewId", "bookId"): frame[column] = ( frame[column].astype("string").str.strip().replace("", pd.NA) ) parsed_rating = pd.to_numeric( frame["rating"].astype("string").str.strip(), errors="coerce" ) valid_rating = parsed_rating.between(1, 5) frame["rating_value"] = parsed_rating.where(valid_rating) frame["created_time"] = pd.to_datetime( frame["createdAt"], errors="coerce", utc=True ) identified = frame.dropna(subset=["bookId", "reviewId"]) audit = { "returned_review_rows": len(frame), "missing_identity": len(frame) - len(identified), "missing_or_invalid_rating": int((~valid_rating.fillna(False)).sum()), "missing_or_invalid_date": int(frame["created_time"].isna().sum()), "omitted_spoiler": int(frame["spoiler"].isna().sum()), "repeated_identity": int( identified.duplicated(["bookId", "reviewId"]).sum() ), } clean = identified.drop_duplicates(["bookId", "reviewId"]).copy() return clean, audit clean, audit = prepare_reviews(items) 

If repeated identities appear, inspect them before accepting the retained row. Deduplication settles counting; it doesn't settle disagreements between versions.

These checks describe the returned records. They can't detect eligible reviews that never reached the dataset.

Put the distribution beside the mean

A mean hides the rating mix and the amount of usable evidence behind it.

Keep the review count, rated count and dated count beside each book's earliest and latest observed timestamps. Missing dates weaken the coverage description even when the remaining range looks plausible.

This cell builds those summaries and attaches the manifest label to both tables.

per_book = clean.groupby("bookId").agg( observed_reviews=("reviewId", "size"), rated_reviews=("rating_value", "count"), mean_stars=("rating_value", "mean"), dated_reviews=("created_time", "count"), earliest_created_at=("created_time", "min"), latest_created_at=("created_time", "max"), ) per_book["at_review_cap"] = ( per_book["observed_reviews"] >= run_input["maxReviewsPerBook"] ) per_book["selection"] = manifest["label"] manifest["at_run_cap"] = len(items) >= run_input["maxItems"] rating_distribution = duckdb.sql(""" SELECT bookId, rating_value AS stars, count(*) AS reviews, count(*) * 1.0 / sum(count(*)) OVER (PARTITION BY bookId) AS share_of_rated_reviews FROM clean WHERE rating_value IS NOT NULL GROUP BY bookId, rating_value ORDER BY bookId, stars """).df() rating_distribution["selection"] = manifest["label"] 

These tables contain observed books, not a roster proving that every requested book returned reviews.

The distribution exposes the retained rating mix. It can't reconstruct excluded categories, and their absence mustn't be presented as a finding about dissatisfaction.

For comparisons across books, weighting needs a name too. Pooling reviews weights books by their returned rated-review counts; averaging book means gives each included book equal weight. Those answer different questions.

Change the selection before polishing the chart

If the intended question covers the available star range, omit the rating thresholds. A sentiment calculation shouldn't first require favourable sentiment.

Other restrictions can define legitimate subjects. English-language reviews can be the intended population; spoiler-free text can be the material for a content study. The problem starts when a narrow question acquires a broad headline.

These alternative inputs vary a selection rule independently, while the function accepts separately supplied pulls.

comparison_inputs = { "selected": run_input.copy(), "without_rating_floor": { key: value for key, value in run_input.items() if key != "reviewRatingMin" }, "all_languages": {**run_input, "reviewLanguage": "all"}, "spoilers_included": {**run_input, "excludeSpoilers": False}, "oldest_first": {**run_input, "reviewSort": "OLDEST"}, } def compare_pulls(pulls): parts = [] for label, records in pulls.items(): prepared, _ = prepare_reviews(records) part = prepared.groupby("bookId").agg( rated_reviews=("rating_value", "count"), mean_stars=("rating_value", "mean"), earliest_created_at=("created_time", "min"), latest_created_at=("created_time", "max"), ).reset_index() part.insert(0, "selection", label) parts.append(part) return pd.concat(parts, ignore_index=True) comparison = compare_pulls({manifest["label"]: items}) 

Only the original collection is supplied here. Add your other datasets under their corresponding labels to calculate differences.

Changing eligibility under a fixed cap can also change the observed time window. Separate collections may additionally reflect changes on the live platform. Treat differences as sensitivity results, not isolated causal effects.

For a shared reporting period, apply the calendar boundary to createdAt after collection and inspect coverage for every book. The input has no review-date range filter. If collection doesn't cover the period, a later date filter can't fill the gap.

Using separate runs per book removes competition for the shared ceiling. It still leaves the per-book limit and source coverage to assess.

Make the methods sentence travel with the number

The worked example uses Goodreads Book, Author & Listopia List Scraper.

Your published subject should match the selected population. The methods text can preserve the operational detail without making readers decipher an input object.

This cell generates that text from the retained configuration, including explicit caps and their defaults.

selection = manifest["selection"] defaults = manifest["defaults"] methods_sentence = ( "We calculated per-book mean star ratings from uniquely identified " "public reviews retrieved for the supplied book selection, " f"ordered {selection['reviewSort']}, with review language " f"{selection['reviewLanguage']} and a minimum star rating of " f"{selection['reviewRatingMin']}. " f"Spoiler-marked reviews excluded: {selection['excludeSpoilers']}. " f"The requested per-book review cap was " f"{selection['maxReviewsPerBook']} " f"(default {defaults['maxReviewsPerBook']}); " f"the run-wide emitted-record cap was {selection['maxItems']} " f"(default {defaults['maxItems']}). " "Reviews without identifiers were excluded and repeated identities " "were counted once. Missing or invalid ratings were excluded from " "means; missing dates were excluded from date ranges." ) 

Publish the counts and observed date ranges alongside it. Retain the input and collection identity so a later rerun can't quietly acquire an older explanation.

The absent readers remain unmeasured

The review record schema doesn't expose a review-language field. The manifest preserves the requested condition, but the returned fields don't independently verify it.

Nor do these records establish reviewers' countries, represent readers who stayed silent, or reveal the ratings of excluded reviews. Platform spoiler labels don't establish reading completion.

The strongest claim available is a precise account of the selected reviews.

Your headline needs the same boundaries as your denominator.

Drafted with AI assistance and reviewed for accuracy.