Positivity¶
get_positivity() returns weekly test positivity: the percentage of
tested samples that were positive for influenza, RSV or SARS-CoV-2.
import pyerviss as pv
df = pv.get_positivity(
pathogen="influenza", setting="primary care", countries="Italy", season="2024/25"
)
df[["setting", "pathogen", "country", "year_week", "value", "unit", "tests", "detections"]]
setting pathogen country year_week value unit tests detections
6 primary care Influenza Italy 2024-W52 28.3 % 120 34
7 primary care Influenza Italy 2025-W01 39.0 % 267 104
8 primary care Influenza Italy 2025-W02 42.8 % 549 235
9 primary care Influenza Italy 2025-W03 47.1 % 715 337
...
The full columns are indicator ("positivity"), setting, pathogen, country,
country_code, year_week, date, age, value, unit, tests and detections.
Data is for all ages combined (age is always "total"). Primary care data starts
in 2014-W25 for influenza, 2016-W40 for RSV and 2020-W03 for SARS-CoV-2; hospital
data starts in 2020-W40. Coverage varies by country.
Settings¶
|
Samples from |
Pairs with |
|---|---|---|
|
patients with ILI and/or ARI seen by sentinel GPs |
|
|
SARI patients in sentinel hospitals |
By default both settings are returned. Primary care positivity is not split by syndrome: depending on the country, sentinel GPs swab ILI patients, ARI patients or both.
Pathogens¶
pathogen takes "influenza", "rsv" or "sars-cov-2" (case-insensitive; "flu" and
"covid" also work), or a list. By default all three are returned; the pathogen
column uses ECDC’s names: "Influenza", "RSV", "SARS-CoV-2".
Positivity is published for influenza overall, not by type or subtype (A(H1)pdm09, A(H3), B/Victoria). For the split of detections by type or subtype, see Types and subtypes.
Tests and detections¶
value is detections / tests × 100, and both counts are returned alongside it.
Use them: many weeks rest on few tests, and positivity from a handful of samples is
noise. A week with 1 test and 1 positive has a positivity of 100%.
df = pv.get_positivity(pathogen="rsv")
df = df[df["tests"] >= 20] # drop weeks with fewer than 20 tests
Weeks with tests but no positivity (for example zero tests) are not returned.
Types and subtypes¶
get_detections() says which kind of influenza or RSV was detected: how
many detections fell into each type or subtype, and that category’s share of all
detections of the pathogen that week.
df = pv.get_detections(pathogen="influenza", setting="primary care", countries="Italy",
season="2025/26", level="subtype")
year_week type subtype value share total
10 2025-W46 A A(H3) 63 0.707865 89
11 2025-W46 A A (unknown) 2 0.022472 89
12 2025-W47 A A(H1)pdm09 22 0.226804 97
13 2025-W47 A A(H3) 74 0.762887 97
14 2025-W47 A A (unknown) 1 0.010309 97
|
Influenza |
RSV |
|---|---|---|
|
|
|
|
|
as |
shareisvalue / total, wheretotalis the sum over all categories of the week, so shares add up to 1. Detections that were not typed or subtyped are kept as categories (untyped,A (unknown),B (unknown)). For shares among subtyped samples only, drop them and rescale:typed = df[~df["subtype"].isin(["A (unknown)", "B (unknown)", "untyped"])] typed = typed.assign(share=typed["value"] / typed.groupby("year_week")["value"].transform("sum"))
ECDC only publishes categories with at least one detection, so a category missing from a week means 0. Pivoting with
fill_value=0gives one column per subtype:df.pivot_table(index="date", columns="subtype", values="share", fill_value=0)
totalmatches the detections ofget_positivity()in almost every week; in a few weeks the categories add up to slightly more.Availability: influenza from 2014 in primary care and 2020 in hospitals; RSV-A/B mostly from 2021; B/Yamagata has not been detected since 2024. SARS-CoV-2 is not split by type.
EU/EEA aggregate¶
ECDC also publishes positivity for the EU/EEA as a whole. Query it like a country, as
"EU/EEA" or with the code "EU":
pv.get_positivity(countries="EU", pathogen="influenza", setting="primary care")
Combining with ILI: pathogen-specific activity¶
Multiplying the ILI rate by influenza positivity in the same week estimates the influenza-attributable ILI rate (often called “ILI+”), a common signal for tracking and forecasting influenza:
ili = pv.get_ili(countries="Italy", season="2024/25", age_groups="total")
pos = pv.get_positivity(
pathogen="influenza", setting="primary care", countries="Italy", season="2024/25"
)
df = ili.merge(pos[["year_week", "value", "tests"]], on="year_week", suffixes=("", "_positivity"))
df["ili_plus"] = df["value"] * df["value_positivity"] / 100
year_week value value_positivity tests ili_plus
6 2024-W52 1050.8 28.3 120 297.4
7 2025-W01 1234.9 39.0 267 481.6
8 2025-W02 1493.5 42.8 549 639.2
9 2025-W03 1602.0 47.1 715 754.5
...
The same works for ARI with RSV or SARS-CoV-2, and for SARI with hospital positivity.
Note
This is an approximation: primary care samples come from ILI and/or ARI patients depending on the country, and sampling is not always representative of all consultations. Weeks with few tests make the estimate noisy.
What is available¶
pv.coverage("positivity") # per setting, pathogen and country
pv.list_countries("positivity")
pv.latest_week("positivity")
setting pathogen country country_code first_week last_week n_weeks unit
3 hospital Influenza EU/EEA EU 2020-W40 2026-W40 314 %
...
62 primary care Influenza Italy IT 2014-W46 2026-W09 248 %