You're about to publish a reputation comparison. The spreadsheet has an average rating, a review count and a reassuringly tidy weighted average.
The weight is where the trouble starts: reviewCount counts client recommendations, while ratingCount counts appraisals containing a rating.
A recommendation count is not automatically the denominator behind an average rating. Weighting avgRating by reviewCount gives you a recommendation-weighted average of profile averages. It doesn't establish an average across individual ratings.
A row is a profile, not a review
The Actor returns freelancer records. Each record can carry a stable profileId, a profile-level rating and several counters, but it doesn't contain the individual appraisals behind those aggregates.
That distinction matters before you write any arithmetic. You can compare public profile summaries; you can't expand a counter into the underlying observations.
This Example input collects profiles without imposing reputation thresholds:
import os
import pandas as pd
import duckdb
from apify_client import ApifyClient
run_input = {
"mode": "searchFreelancers",
"searchQuery": "python developer",
"market": "de",
"maxItems": 20,
}
client = ApifyClient(os.environ["APIFY_TOKEN"])
run = client.actor(
"dataspryva/malt-freelancer-skill-and-rate-finder"
).call(run_input=run_input)
if run["status"] != "SUCCEEDED":
raise RuntimeError(f"Actor status: {run['status']}")
items = client.dataset(run["defaultDatasetId"]).list_items().items
Search returns a randomised public sample, then de-duplicates profiles by their identifier. That makes the returned dataset useful for describing those profiles, without making it a representative survey of freelancers.
Your chart's population starts with the collection method, before missing values get their turn.
The counters describe different evidence
Here's the field map for the reputation comparison. The analytical types below are choices for the loader: the output descriptions give meanings, but don't specify a complete JSON type and formatting contract.
| Field | What it holds | Analytical type | The trap |
|---|---|---|---|
profileId |
Stable profile identifier | Nullable string | Counting rows across combined extracts can count a profile repeatedly. |
avgRating |
Average client rating, bounded by 0–5 | Nullable float | A profile average isn't an individual appraisal, and its exact aggregation formula isn't specified. |
reviewCount |
Client recommendations | Nullable integer | Its name invites you to treat it as the number of rated appraisals. |
ratingCount |
Appraisals containing a rating | Nullable integer | It describes rating volume, but doesn't establish that it is the exact weight behind the supplied average. |
missionsCount |
Completed missions Malt reports | Nullable integer | A mission count isn't an identified population of eligible review invitations. |
The split is easier to see without the familiar word “reviews” doing everyone's job:
Public profile
├─ avgRating → average client rating
├─ reviewCount → recommendations
├─ ratingCount → appraisals containing ratings
└─ missionsCount → reported completed missions
Different counters do not establish shared membership or timing.
A difference between the counters is therefore an audit finding, not automatically an error.
If recommendations exceed rated appraisals, subtraction tells you the numerical gap. It doesn't identify which recommendations lack ratings, or prove that the counters describe nested sets.
Column names are cheap. Set membership is more expensive.
Choose types without inventing a format
Unfilled fields are omitted rather than returned as nulls or placeholders. There's no field-specific promise explaining every possible omission for these counters.
We'd preserve that distinction during ingestion. An absent key, supplied text that won't parse and an out-of-range number should never quietly become the same analytical zero.
The loader below retains the original values, tracks key presence and parses numeric-looking text after trimming whitespace. It deliberately doesn't guess a thousands separator or decimal locale where no formatted numeric convention is specified.
It also keeps malformed or out-of-domain values available for inspection:
fields = [
"profileId", "avgRating",
"reviewCount", "ratingCount", "missionsCount",
]
count_fields = ["reviewCount", "ratingCount", "missionsCount"]
numeric_fields = ["avgRating", *count_fields]
raw = pd.DataFrame(items).reindex(columns=fields)
present = pd.DataFrame(
[{field: field in item for field in fields} for item in items],
columns=fields,
).astype("boolean")
typed = pd.DataFrame(index=raw.index)
typed["profileId"] = (
raw["profileId"].astype("string").str.strip().replace("", pd.NA)
)
audit_parts = []
for field in numeric_fields:
text = raw[field].astype("string").str.strip()
parsed = pd.to_numeric(text, errors="coerce").astype("Float64")
if field == "avgRating":
valid = parsed.between(0, 5).fillna(False)
typed[field] = parsed.where(valid)
else:
valid = (
parsed.ge(0)
& parsed.lt(2**63)
& parsed.mod(1).eq(0)
).fillna(False)
typed[field] = parsed.where(valid).astype("Int64")
audit_parts.append(pd.DataFrame({
"field": field,
"raw_value": raw[field],
"omitted": ~present[field],
"supplied_missing": present[field] & raw[field].isna(),
"parse_failure": raw[field].notna() & parsed.isna(),
"domain_failure": parsed.notna() & ~valid,
}))
audit = pd.concat(audit_parts, ignore_index=True)
The integer storage boundary is a loader constraint, not a claimed marketplace limit. Fractional counts are rejected because counting appraisals or missions requires whole quantities.
For profileId, the string representation is an analytical key; raw retains its original representation. Don't interpret an identifier numerically or use its apparent order as chronology.
Missing fields change who enters the mean
An omitted recommendation count doesn't establish that a freelancer has no recommendations. An omitted rating doesn't belong at the bottom of the rating scale.
Those substitutions would change the story: absence of public evidence would become evidence of poor reputation.
Keep the counters side by side before selecting an average. When combining extracts, also quarantine missing or repeated identifiers until you've decided which observation to retain.
This cell creates the comparison table and calculates gaps only where both operands survive parsing:
identity_ok = (
typed["profileId"].notna()
& ~typed["profileId"].duplicated(keep=False)
)
comparison = typed.copy()
comparison["identity_usable"] = identity_ok
comparison["recommendation_rating_gap"] = (
comparison["reviewCount"] - comparison["ratingCount"]
)
comparison["mission_rating_gap"] = (
comparison["missionsCount"] - comparison["ratingCount"]
)
identity_audit = pd.Series({
"returned_rows": len(typed),
"rows_with_usable_identity": int(identity_ok.sum()),
"rows_requiring_identity_review": int((~identity_ok).sum()),
})
The gaps remain missing when either input is unavailable. Filling those gaps would manufacture relationships between quantities you haven't observed.
Duplicate identifiers deserve similar restraint. Silently keeping the first row can select an older or less complete observation merely because it arrived first.
Which average are you publishing?
An unweighted mean of avgRating gives equal influence to each included profile with a usable average.
Weighting by ratingCount emphasises profiles with more rated appraisals; using reviewCount instead emphasises recommendation volume.
Those are different estimands: different quantities your calculation is trying to describe.
Even the more intuitively relevant appraisal count leaves an arithmetic catch: if supplied averages are rounded, multiplying them back by counts needn't recover the underlying rating total.
This cell calculates explicitly labelled alternatives and retains the contributing population for each:
profiles = typed.loc[identity_ok].copy()
rated = profiles["avgRating"].notna()
def weighted_profile_mean(frame, weight_field):
usable = (
frame["avgRating"].notna()
& frame[weight_field].gt(0).fillna(False)
)
subset = frame.loc[usable]
weights = subset[weight_field].astype("Float64")
weight_sum = weights.sum(min_count=1)
numerator = (
subset["avgRating"] * weights
).sum(min_count=1)
mean = (
numerator / weight_sum
if pd.notna(weight_sum) and weight_sum > 0
else pd.NA
)
return {
"mean": mean,
"contributing_profiles": len(subset),
"weight_sum": weight_sum,
}
estimates = pd.DataFrame.from_dict({
"unweighted_profile_average": {
"mean": profiles.loc[rated, "avgRating"].mean(),
"contributing_profiles": int(rated.sum()),
"weight_sum": pd.NA,
},
"rating_count_weighted_profile_average":
weighted_profile_mean(profiles, "ratingCount"),
"recommendation_weighted_profile_average":
weighted_profile_mean(profiles, "reviewCount"),
}, orient="index")
Don't compare those means without comparing their contributing profiles. Missing weights can change both the weighting and the membership of the calculation.
For publication, “mean public profile rating among returned profiles with usable ratings” is defensible wording. “Average client satisfaction” claims a broader population and a measurement interpretation these aggregates don't establish.
Thresholds don't create a rated sample
The inputs minRating and minReviews filter present values below their thresholds. Profiles without the corresponding public value aren't excluded.
That means a filtered result isn't automatically a collection of rated, sufficiently reviewed profiles. You still need an explicit analytical eligibility rule after collection.
The input types also differ: minRating accepts a number, while minReviews accepts an integer. Neither input becomes an output counter you can audit row by row.
Keep your chosen input settings with your analysis. If you later exclude missing ratings locally, report that exclusion separately from the Actor's threshold behaviour.
The worked example uses Malt Freelancer Skill & Rate Finder. Its thresholds define collection rules; your publication needs a separate statement of analytical eligibility.
Keep the denominator audit beside the chart
You need to know how many profiles contribute to each proposed figure before deciding which figure earns a headline.
This DuckDB query counts usable fields and the paired, positive-weight populations used by the weighted calculations:
connection = duckdb.connect()
connection.register("reputation_profiles", profiles)
denominator_audit = connection.execute("""
SELECT
COUNT(*) AS profiles_with_usable_identity,
COUNT("avgRating") AS profiles_with_rating,
COUNT("reviewCount") AS profiles_with_recommendations,
COUNT("ratingCount") AS profiles_with_appraisal_count,
COUNT("missionsCount") AS profiles_with_mission_count,
COUNT(*) FILTER (
WHERE "avgRating" IS NOT NULL
AND "ratingCount" > 0
) AS rating_weight_eligible_profiles,
COUNT(*) FILTER (
WHERE "avgRating" IS NOT NULL
AND "reviewCount" > 0
) AS recommendation_weight_eligible_profiles
FROM reputation_profiles
""").df()
connection.close()
Keep denominator_audit, identity_audit and the parsing audit with the calculation. They explain why a returned profile did or didn't contribute, rather than leaving that decision buried in pandas' missing-value handling.
If you compare groups, apply the same audit within each group. Equal-looking averages can rest on very different amounts of public evidence.
Rating volume describes evidence quantity. It doesn't independently establish service quality.
A mission count can't supply a response rate
Dividing ratingCount by missionsCount produces a ratio of public counters. Calling it a review response rate requires more: an eligible population, aligned observation periods and a known relationship between missions and appraisal opportunities.
These records don't establish those conditions. You can't infer the experiences of clients who left no visible appraisal.
A defensible denominator needs a population, not just a convenient column.
Drafted with AI assistance and reviewed for accuracy.
Top comments (0)