Group by Time Period
The retime function adjusts row times to create specified intervals, either by resampling or grouping
values. Its pre-defined intervals range from seconds to years, and you can specify how to handle
missing or multiple values for the intervals. For instance, you can select the first observation from
each week, or count observations in a quarter.
For the outage data, you can use retime to find totals for each year. First, create a timetable with
only numeric variables. Then, call retime and specify a yearly interval, combining multiple values
using a sum. The output has one row for each year, containing the total losses and total customers
affected during that year.
numTT = TT(:,vartype("numeric"));
numTT = retime(numTT,"yearly","sum");
head(numTT,5)
ans=5×2 timetable
OutageTime
Loss
Customers
________________
_____
__________
2002-01-01 00:00
81335
1.3052e+07
2003-01-01 00:00
58036
1.396e+07
2004-01-01 00:00
51014
1.5523e+07
2005-01-01 00:00
33980
8.7334e+06
2006-01-01 00:00
35129
2.5729e+07
Create a bar chart of the number of customers affected each year.
Select Times in Timetable
10-23
Précédent

- 469/1450

Suivant