# Convert to a (5,24*366) annual series: each row is a year, each
column an hour
# Because of lapse years, we have 24*366 cols, not 24*365
a_s_all = s_all.convert('A')
# If the first column (the first date) is masked, mask the row.
a_s_all[a_s_all[:,0].mask] = ma.masked
# If the column -25 (last hour of 12/31 or 12/30) is masked, masked
the column
a_s_all[a_s_all[:,-25].mask] = ma.masked
# Make a new series from the annual series.
# We can't us convert because the annual series is 2D.
# Instead, we create a new series starting at the first date of the
annual series,
# converted to the correct frequency (s_all.freq).
# As the method asfreq defaults to END, we need to force 'START' for
relation
# (check the docstring of asfreq).
starting_date = a_s_all.dates[0].asfreq(s_all.freq, relation='START')
# For the data, we can't use a_s_all.ravel() directly because a_s_all
is 2D,
# but we only need the data actually, not the dates.
s_new = ts.time_series(a_s_all._series.ravel(),
start_date=starting_date)
# And if you want, you can force the starting and ending dates of this
new series
# to the initial ones
s_mod = ts.align_with(s_all, s_new)