Your pandas mean says 38.33. The plant historian says 31.38
Historians usually store a value only when it changes enough, so each row covers a different stretch of time, and weighting every row equally gives the wrong report.
In brief
- Historians compress data, so a single row can stand for one second or several hours, and a plain mean of rows is pulled toward the moments when the signal moves.
- In GE's example the same tag gives 38.33 by row and 31.38 by time; TigerData's freezer example gives 10.2 versus about 6.64.
- 'Average' in GE Historian is time-weighted, while in OPC UA it counts samples, so pin down the definition before comparing numbers.
- 114:00:00 · value 30Holds for 60 seconds; the raw average drops this sample because it sits exactly on the start boundary
- 214:01:00 · value 40Holds for 10 seconds
- 314:01:10 · value 50Holds for 5 seconds
- 414:01:15 · value 20, Bad30 seconds excluded from both numerator and denominator
- 514:01:45 · value 25Holds for 15 seconds, until the interval ends at 14:02:00
- 6ResultUnfiltered mean() 33; RawAverage 38.33; time-weighted 31.38
The value 30 accounts for 60 of the 90 Good seconds, so the time-weighted average (31.38) sits well below the row average (38.33).
Graphic: FDE Times
The GE Historian 8.0 documentation contains a small example that every FDE working with plant data should know by heart. One tag, TAG2, about two minutes, five samples. The raw average returns 38.33. The time-weighted average returns 31.38.
Pull those five rows into pandas and call mean() without filtering, and you get 33, because the calculation keeps both the sample at the start boundary and the Bad sample. Filter the way RawAverage does and you get 38.33. Both are row averages, while the historian screen the client’s operations engineer is looking at may show 31.38.
The next meeting will be about who got it wrong, and the first suspect is usually your dashboard. So it pays to understand exactly why the numbers diverge, how to compute the right one yourself, and the naming traps that catch even experienced engineers.
Not every row weighs the same
The root of the problem is compression. With deadband filtering, a historian ignores a new value unless it differs from the last stored value by more than a preset threshold. In GE’s case, compression also runs in the collector, before data reaches the archive, so not every change at the source gets stored.
Some systems do not record only on change: Ignition has a Max Time Between Samples setting that forces a value to be stored after a maximum number of Tag Group executions.
Without a setting like that, the number of stored rows tracks how volatile the signal is rather than the clock. When the process is stable a single row can stand for a long time; during an upset, rows pile up densely.
A row-by-row arithmetic mean implicitly assumes each row represents the same amount of time. With compressed data that assumption is false, and the result is dragged toward the periods when the signal fluctuates most, where samples are recorded more densely.
TigerData’s freezer example makes the point clearly. The ordinary average comes out at 10.2℉, the time-weighted average at about 6.64℉, while the freezer was above threshold for only 5 of 45 minutes (about 11% of the time). A report saying “average temperature 10.2” could easily convince a quality manager the freezer failed for the whole shift, when something was wrong only about 11% of the time.
Recomputing TAG2 step by step
GE’s data: 30 at 14:00:00, 40 at 14:01:00, 50 at 14:01:10, 20 at 14:01:15 with Bad quality, and 25 at 14:01:45. The query interval ends at 14:02:00.
The raw average drops the 30 that sits exactly on the start boundary, drops the Bad sample, then divides evenly: (40 + 50 + 25) / 3 = 38.33. The time-weighted average holds each value until the next sample: 30 holds for 60 seconds, 40 for 10 seconds, 50 for 5 seconds, 25 for 15 seconds.
The Bad sample is skipped, so its 30 seconds appear in neither the numerator nor the denominator, and the total time counted is only 90 of 120 seconds.
samples = [ # (timestamp, value, quality)
("14:00:00", 30, "Good"),
("14:01:00", 40, "Good"),
("14:01:10", 50, "Good"),
("14:01:15", 20, "Bad"),
("14:01:45", 25, "Good"),
]
start, end = "14:00:00", "14:02:00"
def sec(t):
h, m, s = map(int, t.split(":"))
return h * 3600 + m * 60 + s
# 0) Unfiltered mean(): keeps both the start-boundary sample and the Bad sample
print(sum(v for _, v, _ in samples) / len(samples)) # 33.0
# 1) Row average, RawAverage-style as in GE's example
raw = [v for t, v, q in samples if q == "Good" and sec(t) > sec(start)]
print(round(sum(raw) / len(raw), 2)) # 38.33
# 2) Time-weighted average, last observation carried forward (LOCF), Bad stretches dropped
area, good_time = 0, 0
for i, (t, v, q) in enumerate(samples):
t_next = samples[i + 1][0] if i + 1 < len(samples) else end
dur = sec(t_next) - sec(t)
if q == "Good":
area += v * dur
good_time += dur
print(round(area / good_time, 2)) # 31.39
The code returns 31.39 rather than 31.38. The reason is on the GE page itself: the expression printed there uses 59.999 in the numerator but 60 in the denominator, and that same expression works out to about 31.389, so the published figure appears to have been truncated rather than rounded.
That suggests a habit worth building: when reconciling against a historian, do not expect agreement to the last digit, and rebuild the calculation yourself instead of trusting the printed number.
The code also simplifies one thing. It happens to have a sample exactly at 14:00:00; with real data you have to fetch the last value before the start boundary to know where the tag stood when the interval opened.
The biggest trap is the word “Average”
It is tempting to think calling the system’s Average aggregate settles it. It does not. In GE Historian, the mode named Average is time-weighted, and RawAverage is the arithmetic mean of good-quality raw samples.
The OPC UA Part 13 standard is the reverse. Its Average aggregate sums every Good raw value in the interval and divides by the number of Good values, which makes it a sample-count average. The time-weighted version has its own name, TimeAverage: it uses interpolated boundary values, joins the points with sloped lines, and divides the area under the line by the length of the interval.
PIconnect, the Python library for reading the PI System, defaults to time weighting: each event counts for the span during which it was in effect, and equal weights require choosing the event-weighted option.
| System | By row | By time |
|---|---|---|
| GE Historian | RawAverage | Average |
| OPC UA Part 13 | Average | TimeAverage |
| PIconnect (PI System) | Event-weighted option | Default |
| Kusto (Microsoft) | avg() | time_weighted_avg_fl() |
| dataPARC | /AVG | /TAVG |
If a client has an OPC UA gateway sitting in front of a GE historian, the same word “Average” can yield two different numbers depending on which door you ask through.
Steps or slopes?
Once you have chosen time weighting, one decision remains: how the value behaves between two samples. GE’s TAG2 example and Kusto’s time_weighted_avg_fl() both use a stepped model, holding each value until the timestamp of the next. OPC UA’s TimeAverage joins points with sloped lines.
Judged by how equipment behaves, tags that change only in discrete steps, such as setpoints or valve states, suit the stepped model, because the device really does stay put between recordings. For continuously varying analog tags, sloped interpolation may be closer to reality, but that is an inference, so check it against each tag’s recording configuration.
Five steps when you receive a historian dataset
First, ask the operations team how the tag is recorded: on change, with what deadband, and whether there is a maximum recording interval. The answer decides whether you use steps or interpolation.
Second, look up the aggregate documentation for that specific system rather than guessing from the name. Third, handle the boundaries: fetch the value before the start boundary, and exclude Bad samples the way the historian does. Fourth, compute one test interval by hand and reconcile it against the historian. Fifth, record your choices in the handover documentation so the next person does not quietly switch back to mean().
Common mistakes
The most common mistake is resampling compressed data by taking the arithmetic mean of rows in each window, then feeding it straight into a model or KPI. The second is applying linear interpolation to a stepped tag, which invents intermediate values the equipment never had.
The third is harder to spot: believing that recomputing by time will fix everything. Deadband discards small changes at the collector, so fluctuations inside the threshold leave no trace, and no calculation can recover them. If the client needs to catch short events, the fix is to change the compression configuration.
The last mistake is demanding that the numbers match exactly. Steps and slopes give different results on the same data, and GE’s own documentation prints 31.38 for an expression that comes out at 31.389. Being able to explain that gap in one sentence is what earns a client’s trust.
Three TAG2 numbers are worth more than “proficient in pandas”
This skill is hard to prove with a list of tools, but easy to prove with a small public notebook.
Rebuild TAG2 and the freezer example, and write a time-weighted average function that takes a stepped-or-interpolated parameter, fetches the value before the start boundary and excludes Bad samples.
The README only needs to answer three questions: why 33, why 38.33, why 31.38.
If a technical round hands you a sensor time-series exercise, ask before you code: is the tag recorded on change or on a fixed cycle, what is the deadband, and are you reading through the historian or through an OPC UA gateway. Those three questions show the interviewer you know one row of data is not one unit of time.
On your CV, write in terms that can be verified, for example “found a KPI skewed by row averaging on compressed data, switched to a time-weighted average, reconciled it against the historian’s aggregate.” If you can also note how you handled Bad samples and boundary values, that line answers the hardest interview question before it is asked.
Was this article useful?
Thanks for the feedback!
11 sources
- Time Weighted Calculation Modes | Historian 8.0 Documentation | GE Vernova
- CalculationModeType Parameter
- Notes on Collector and Archive Compression
- Why do data historians compress data? · 2026-09-15
- Configuring Tag History | Ignition User Manual · 2026-09-08
- What Time-Weighted Averages Are and Why You Should Care · 2021-07-22
- Average – OPC Unified Architecture - Part 13: Aggregates
- OPC Unified Architecture - Part 13: Aggregates (5.4.3.6 TimeAverage)
- PIconnect docs/tutorials/summaries.rst
- time_weighted_avg_fl() - Kusto | Microsoft Learn · 2024-08-11
- Aggregates