Merging, Splicing and Blending Time Series

This tutorial demonstrates the usage and difference between ts_merge, ts_splice and ts_blend, three methods for folding together time series into a combined data structure.

  • ``ts_merge`` blends multiple time series together based on priority, optionally filling missing values in higher priority series with entries from lower priority. It potentially uses all the input series at all timestamps. See the `strict_priority <#ts_merge-strict-priority-option>`__ option below for advanced control over nan-filling between priorities.

  • ``ts_splice`` stitches together time series in sequential time blocks without mixing values.

  • ``ts_blend`` fills gaps by priority like ts_merge, but ramps the lower-priority series in on the shoulders of each gap so there is no jump where the gap begins or ends. See Blending near gaps below.

We will describe the effect on regularly sampled series (which have the freq attribute) and on irregular. We will also explore the ``names`` argument, which controls how columns are selected or renamed in the merging/splicing process. There is a file-level command line tools for this as well in the dms_datastore package.

Prioritized filling on regular series

Let’s begin by showing how ts_merge and ts_splice fold together two regular series but gappy series on a prioritized basis.

Here are the sample series:

[1]:
import pandas as pd
import numpy as np
from vtools import ts_merge, ts_splice
# ========================================
# Creating Regular Time Series (1D Frequency with Missing Data)
# ========================================
idx1 = pd.date_range("2023-01-01", periods=10, freq="1D")
idx2 = pd.date_range("2023-01-01", periods=12, freq="1D")
idx3 = pd.date_range("2022-12-31", periods=14, freq="1D")

series1 = pd.Series([1, np.nan, 3, np.nan, 5, 6, np.nan, 8, 9, 10], index=idx1, name="A")
series2 = pd.Series([np.nan, 2, np.nan, 4, np.nan, np.nan, 7, np.nan, np.nan, np.nan,3.,4.], index=idx2, name="A")
series3 = pd.Series([1000.,1001., 1002., np.nan, 1004., np.nan, np.nan, 1007., np.nan, np.nan, np.nan,1005.,1006.,1007.], index=idx3, name="A")

print("Series 1 (Primary):")
display(series1)

print("\nSeries 2 (Secondary - Fills Gaps):")
display(series2)

print("\nSeries 3 (Tertiary - Fills Gaps):")
display(series3)




Series 1 (Primary):
C:\Users\eli\miniconda3\envs\schism\Lib\site-packages\numpy\lib\_format_impl.py:838: VisibleDeprecationWarning: dtype(): align should be passed as Python or NumPy boolean but got `align=0`. Did you mean to pass a tuple to create a subarray type? (Deprecated NumPy 2.4)
  array = pickle.load(fp, **pickle_kwargs)
2023-01-01     1.0
2023-01-02     NaN
2023-01-03     3.0
2023-01-04     NaN
2023-01-05     5.0
2023-01-06     6.0
2023-01-07     NaN
2023-01-08     8.0
2023-01-09     9.0
2023-01-10    10.0
Freq: D, Name: A, dtype: float64

Series 2 (Secondary - Fills Gaps):
2023-01-01    NaN
2023-01-02    2.0
2023-01-03    NaN
2023-01-04    4.0
2023-01-05    NaN
2023-01-06    NaN
2023-01-07    7.0
2023-01-08    NaN
2023-01-09    NaN
2023-01-10    NaN
2023-01-11    3.0
2023-01-12    4.0
Freq: D, Name: A, dtype: float64

Series 3 (Tertiary - Fills Gaps):
2022-12-31    1000.0
2023-01-01    1001.0
2023-01-02    1002.0
2023-01-03       NaN
2023-01-04    1004.0
2023-01-05       NaN
2023-01-06       NaN
2023-01-07    1007.0
2023-01-08       NaN
2023-01-09       NaN
2023-01-10       NaN
2023-01-11    1005.0
2023-01-12    1006.0
2023-01-13    1007.0
Freq: D, Name: A, dtype: float64

And here is what it looks like spliced instead of merged.

[2]:
# ========================================
# 2️⃣ Using `ts_merge()` with Prioritization
# ========================================
merged_series = ts_merge((series1, series2, series3))
print("\nMerged Series with Prioritization:")
display(merged_series)

Merged Series with Prioritization:
2022-12-31    1000.0
2023-01-01       1.0
2023-01-02       2.0
2023-01-03       3.0
2023-01-04       4.0
2023-01-05       5.0
2023-01-06       6.0
2023-01-07       7.0
2023-01-08       8.0
2023-01-09       9.0
2023-01-10      10.0
2023-01-11       3.0
2023-01-12       4.0
2023-01-13    1007.0
Freq: D, Name: A, dtype: float64

Splicing

Splicing marches through the prioritized list of input time series and exclusively uses values for the higher priority series one during the entire span of that series.

[3]:
spliced_series = ts_splice((series1, series2, series3))
print("\nSpliced Series with Prioritization and default `prefer last`:")
display(spliced_series)
spliced_first = ts_splice((series1, series2, series3),transition="prefer_first")
print("\nSpliced Series with Prioritization, Prefer first:")
display(spliced_first)

Spliced Series with Prioritization and default `prefer last`:
2022-12-31    1000.0
2023-01-01    1001.0
2023-01-02    1002.0
2023-01-03       NaN
2023-01-04    1004.0
2023-01-05       NaN
2023-01-06       NaN
2023-01-07    1007.0
2023-01-08       NaN
2023-01-09       NaN
2023-01-10       NaN
2023-01-11    1005.0
2023-01-12    1006.0
2023-01-13    1007.0
Freq: D, Name: A, dtype: float64

Spliced Series with Prioritization, Prefer first:
2022-12-31       NaN
2023-01-01       1.0
2023-01-02       NaN
2023-01-03       3.0
2023-01-04       NaN
2023-01-05       5.0
2023-01-06       6.0
2023-01-07       NaN
2023-01-08       8.0
2023-01-09       9.0
2023-01-10      10.0
2023-01-11       3.0
2023-01-12       4.0
2023-01-13    1007.0
Freq: D, Name: A, dtype: float64

Irregular series

Now we will look at some irregular series and see the difference in output from ts_merge (which shuffles) and ts_splice (which exclusively uses values from one series at a time based on the span of the series and its priority)

[4]:

# ======================================== # 3️⃣ Creating Irregular Time Series (No Freq Attribute) # ======================================== idx_irreg1 = pd.to_datetime(["2023-01-01", "2023-01-03", "2023-01-07", "2023-01-10"]) idx_irreg2 = pd.to_datetime(["2023-01-02", "2023-01-04", "2023-01-08", "2023-01-11"]) series_irreg1 = pd.Series([1, np.nan, 3, 4], index=idx_irreg1, name="A") series_irreg2 = pd.Series([10, 20, np.nan, 40], index=idx_irreg2, name="A") print("\nIrregular Series 1:") display(series_irreg1) print("\nIrregular Series 2:") display(series_irreg2) # ======================================== # 4️⃣ Using `ts_merge()` with Irregular Time Series # ======================================== merged_irregular = ts_merge((series_irreg1, series_irreg2)) print("\nMerged Irregular Series (May Shuffle Timestamps):") display(merged_irregular) # ======================================== # 5️⃣ Using `ts_splice()` with Irregular Time Series # ======================================== spliced_irregular = ts_splice((series_irreg1, series_irreg2), transition="prefer_last") print("\nSpliced Irregular Series (prefer_last):") display(spliced_irregular)

Irregular Series 1:
2023-01-01    1.0
2023-01-03    NaN
2023-01-07    3.0
2023-01-10    4.0
Name: A, dtype: float64

Irregular Series 2:
2023-01-02    10.0
2023-01-04    20.0
2023-01-08     NaN
2023-01-11    40.0
Name: A, dtype: float64

Merged Irregular Series (May Shuffle Timestamps):
D:\Delta\_git_repos\vtools3\vtools\functions\merge.py:151: UserWarning: ts_merge(..., preserve_freq=False, strict_priority=False) may produce irregular union-index artifacts; this mode is not recommended.
  fallback_builder=lambda seq: _merge_output_index_irregular(
2023-01-01     1.0
2023-01-02    10.0
2023-01-03     NaN
2023-01-04    20.0
2023-01-07     3.0
2023-01-08     NaN
2023-01-10     4.0
2023-01-11    40.0
Name: A, dtype: float64

Spliced Irregular Series (prefer_last):
2023-01-01     1.0
2023-01-02    10.0
2023-01-04    20.0
2023-01-08     NaN
2023-01-11    40.0
Name: A, dtype: float64

Names argument

Finally let’s look at some more intricate examples with mixed series and dataframes with differing numbers of columns and see how names can be used to make selections or unify poorly coordinated labels. Here are the series:

[5]:
import pandas as pd
import numpy as np
from vtools import ts_merge, ts_splice  # Assuming these functions are in merge.py

# Create irregular time series
idx1 = pd.date_range("2023-01-01", periods=5, freq="2D")
idx2 = pd.date_range("2023-01-02", periods=5, freq="2D")

series1 = pd.Series([1, np.nan, 3, 4, 5], index=idx1, name="A")
series2 = pd.Series([10, 20, 30, np.nan, 50], index=idx2, name="B")

df1 = pd.DataFrame({"A": [1, np.nan, 3, 4, 5], "B": [10, 20, 30, 40, 50]}, index=idx1)
df2 = pd.DataFrame({"A": [10, 20, np.nan, 40, 50], "B": [100, 200, np.nan, 400, 500]}, index=idx2)
df3 = pd.DataFrame({"A": [310, 320, np.nan, 340, np.nan],
                    "B": [100, 200, np.nan, 400, 500],
                    "C": [3100, 3200, np.nan, 3400, 3500]
                    }, index=idx2)

# Display Data
print("Series 1:")
display(series1)

print("Series 2:")
display(series2)

print("DataFrame 1:")
display(df1)

print("DataFrame 2:")
display(df2)

print("DataFrame 3:")
display(df3)

Series 1:
2023-01-01    1.0
2023-01-03    NaN
2023-01-05    3.0
2023-01-07    4.0
2023-01-09    5.0
Freq: 2D, Name: A, dtype: float64
Series 2:
2023-01-02    10.0
2023-01-04    20.0
2023-01-06    30.0
2023-01-08     NaN
2023-01-10    50.0
Freq: 2D, Name: B, dtype: float64
DataFrame 1:
A B
2023-01-01 1.0 10
2023-01-03 NaN 20
2023-01-05 3.0 30
2023-01-07 4.0 40
2023-01-09 5.0 50
DataFrame 2:
A B
2023-01-02 10.0 100.0
2023-01-04 20.0 200.0
2023-01-06 NaN NaN
2023-01-08 40.0 400.0
2023-01-10 50.0 500.0
DataFrame 3:
A B C
2023-01-02 310.0 100.0 3100.0
2023-01-04 320.0 200.0 3200.0
2023-01-06 NaN NaN NaN
2023-01-08 340.0 400.0 3400.0
2023-01-10 NaN 500.0 3500.0

Here are some example usage:

[6]:
# Example: Using `names` to rename output columns
print("Original univariate series")
print(series1)
print(series2)

# Merging univariate with different names and using names to rename
merged_series_named = ts_merge((series1, series2), names=["C"])
print("Merged univariate series renamed:")
display(merged_series_named)


# Select specific columns in DataFrame
try:
    merged_df_named = ts_merge((df1, df2, df3), names=None)
except:
    print("Merged DataFrame without Selected Columns (names=None) results in an error if the columns don't match")
#display(merged_df_named)

# Select specific columns in DataFrame
merged_df_named = ts_merge((df1, df2), names=None)
print("Merged DataFrame without selected columns (names=None) for input DataFrames with matched columns:")
display(merged_df_named)


# Select specific columns in DataFrame
merged_df_named = ts_merge((df1, df2, df3), names=["A"])
print("Merged DataFrame with Selected Columns A merges that column ([A,B] would have been OK too)")
display(merged_df_named)


# Rename column in splicing
spliced_series_named = ts_splice((series1, series2), names="Renamed_A", transition="prefer_last")
print("Spliced Series with Renamed Column:")
display(spliced_series_named)

Original univariate series
2023-01-01    1.0
2023-01-03    NaN
2023-01-05    3.0
2023-01-07    4.0
2023-01-09    5.0
Freq: 2D, Name: A, dtype: float64
2023-01-02    10.0
2023-01-04    20.0
2023-01-06    30.0
2023-01-08     NaN
2023-01-10    50.0
Freq: 2D, Name: B, dtype: float64
Merged univariate series renamed:
2023-01-01    1.0
2023-01-03    NaN
2023-01-05    3.0
2023-01-07    4.0
2023-01-09    5.0
Freq: 2D, Name: C, dtype: float64
Merged DataFrame without Selected Columns (names=None) results in an error if the columns don't match
Merged DataFrame without selected columns (names=None) for input DataFrames with matched columns:
A B
2023-01-01 1.0 10
2023-01-03 NaN 20
2023-01-05 3.0 30
2023-01-07 4.0 40
2023-01-09 5.0 50
Merged DataFrame with Selected Columns A merges that column ([A,B] would have been OK too)
A
2023-01-01 1.0
2023-01-03 NaN
2023-01-05 3.0
2023-01-07 4.0
2023-01-09 5.0
Spliced Series with Renamed Column:
2023-01-01    1.0
2023-01-03    NaN
2023-01-05    NaN
2023-01-07    NaN
2023-01-09    NaN
Freq: 2D, Name: Renamed_A, dtype: float64

Summary

  • Use ``ts_merge`` when you want to blend time series together, filling missing values in order of priority.

  • Use ``ts_splice`` when you want to keep each time series separate and transition from one to another based on time.

  • Use ``ts_blend`` when you want priority filling like ts_merge but without a jump at gap edges (see below).

  • The ``names`` argument allows you to rename output columns or select specific columns when merging/splicing DataFrames.

This notebook provides a clear comparison to help you decide which method best suits your use case.

ts_merge: strict priority option

New option: strict_priority (default False) enforces that a higher‑priority series dominates between its first_valid_index and last_valid_index.

Semantics

  • Per column, define the dominance window as [first_valid_index, last_valid_index].

  • Within that window, lower‑priority series are masked, even if the higher‑priority value is NaN.

  • Outside those windows, merging is unchanged and lower priority may contribute.

  • With irregular inputs, timestamps that exist only in lower‑priority series and are fully masked inside a dominance window are dropped; timestamps from the top series’ index are preserved even if all‑NaN.

``names`` behavior is unchanged. ### Example 1 — Series with interior NaN

import numpy as np, pandas as pd
from vtools.functions.merge import ts_merge

idx1 = pd.date_range("2023-01-01", periods=5, freq="D")
idx2 = pd.date_range("2023-01-03", periods=5, freq="D")
s1 = pd.Series([1, 2, np.nan, 4, 5], index=idx1, name="A")
s2 = pd.Series([10, 20, 30, np.nan, 50], index=idx2, name="A")

ts_merge((s1, s2))                      # default
ts_merge((s1, s2), strict_priority=True)
idx1 = pd.date_range("2023-01-01", periods=5, freq="D")
idx2 = pd.date_range("2023-01-03", periods=5, freq="D")
df1 = pd.DataFrame({"A":[1., np.nan, 3., 4., 5.]}, index=idx1)
df1["B"] = df1["A"]
df1.loc[idx1[2], "B"] = np.nan  # interior NaN in high‑priority B
df2 = pd.DataFrame({"A":[10., 20., np.nan, 40., 50.]}, index=idx2)
df2["B"] = df2["A"]

ts_merge((df1, df2), strict_priority=True)[["A","B"]]
idx1 = pd.to_datetime(["2023-01-01","2023-01-03","2023-01-07","2023-01-10"])
idx2 = pd.to_datetime(["2023-01-02","2023-01-04","2023-01-08","2023-01-11"])
s1 = pd.Series([1.,2.,3.,4.], index=idx1, name="A")
s2 = pd.Series([10.,20.,30.,40.], index=idx2, name="A")

ts_merge((s1, s2), strict_priority=True)
[7]:
import numpy as np, pandas as pd
from vtools.functions.merge import ts_merge

# Example 1
idx1 = pd.date_range("2023-01-01", periods=5, freq="D")
idx2 = pd.date_range("2023-01-03", periods=5, freq="D")
s1 = pd.Series([1, 2, np.nan, 4, 5], index=idx1, name="A")
s2 = pd.Series([10, 20, 30, np.nan, 50], index=idx2, name="A")
print("Example 1 strict=False:")
print(ts_merge((s1, s2)))
print("Example 1 strict=True:")
print(ts_merge((s1, s2), strict_priority=True))

# Example 2
df1 = pd.DataFrame({"A":[1., np.nan, 3., 4., 5.]}, index=idx1)
df1["B"] = df1["A"]; df1.loc[idx1[2], "B"] = np.nan
df2 = pd.DataFrame({"A":[10., 20., np.nan, 40., 50.]}, index=idx2)
df2["B"] = df2["A"]
print("\nExample 2 strict=True:")
print(ts_merge((df1, df2), strict_priority=True)[["A","B"]])

# Example 3
idx1i = pd.to_datetime(["2023-01-01","2023-01-03","2023-01-07","2023-01-10"])
idx2i = pd.to_datetime(["2023-01-02","2023-01-04","2023-01-08","2023-01-11"])
s1i = pd.Series([1.,2.,3.,4.], index=idx1i, name="A")
s2i = pd.Series([10.,20.,30.,40.], index=idx2i, name="A")
print("\nExample 3 strict=True:")
print(ts_merge((s1i, s2i), strict_priority=True))

Example 1 strict=False:
2023-01-01     1.0
2023-01-02     2.0
2023-01-03    10.0
2023-01-04     4.0
2023-01-05     5.0
2023-01-06     NaN
2023-01-07    50.0
Freq: D, Name: A, dtype: float64
Example 1 strict=True:
2023-01-01     1.0
2023-01-02     2.0
2023-01-03     NaN
2023-01-04     4.0
2023-01-05     5.0
2023-01-06     NaN
2023-01-07    50.0
Freq: D, Name: A, dtype: float64

Example 2 strict=True:
               A     B
2023-01-01   1.0   1.0
2023-01-02   NaN   NaN
2023-01-03   3.0   NaN
2023-01-04   4.0   4.0
2023-01-05   5.0   5.0
2023-01-06  40.0  40.0
2023-01-07  50.0  50.0

Example 3 strict=True:
2023-01-01     1.0
2023-01-03     2.0
2023-01-07     3.0
2023-01-10     4.0
2023-01-11    40.0
Name: A, dtype: float64

Blending near gaps: ts_blend

The functions shown above (ts_merge and ts_splice) perform hard selections:

  • ``ts_merge`` picks the first non-NaN value in priority order at each timestamp.

  • ``ts_splice`` constructs a piecewise record by switching sources at explicit transition times.

In some workflows, however, abrupt switches in the merged product create undesirable jumps. Often the higher-priority series is preferred, but it may contain gaps. In those regions it is useful to fade in the lower-priority series near the edges of gaps rather than switching immediately.

ts_blend implements exactly that:

  • Takes a list of Series/DataFrames (higher priority first).

  • Aligns them onto a common union index.

  • Inside gaps of the high-priority series: falls back to lower-priority data (just like ts_merge).

  • On the shoulders of gaps: computes the distance to the nearest gap in the high-priority series and applies a smooth kernel.

For a gap-edge point with distance \(d\) from the nearest NaN and a user-specified blending radius \(L\):

\[\tilde t = \frac{L - d}{L}, \qquad w_{\mathrm{lo}} = \tilde t, \qquad w_{\mathrm{hi}} = 1 - w_{\mathrm{lo}}.\]

Thus:

  • The lower-priority weight ramps linearly toward the gap: with blend_length=4 the shoulder points at distances 1, 2, 3, 4 get 75%, 50%, 25%, 0% lower-priority, and the first gap point gets 100%, so there is no step where the gap begins.

  • Points farther than blend_length away use 100% of the high-priority value.

  • Inside gaps, the lower-priority series is used exactly.

  • If the lower-priority series is also missing at some point, the output remains NaN.

blend_length can be:

  • an integer → interpreted as a number of samples, or

  • a timedelta-like string (e.g. "2h", "1d") → interpreted as a time window (requires a regular DatetimeIndex with .freq set).

Setting blend_length=None makes ts_blend behave like a standard priority merge.

[8]:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

from vtools.functions.blend import ts_blend

# Daily series: the high-priority series has one 3-day gap; the lower-priority
# series is complete but offset by +2 so the blending is easy to see.
idx = pd.date_range("2023-01-01", periods=17, freq="D")
base = 5.0 + 3.0 * np.sin(np.arange(len(idx)) / 3.0)

hi = pd.Series(base, index=idx, name="hi")
hi.iloc[7:10] = np.nan
lo = pd.Series(base + 2.0, index=idx, name="lo")

blend_length = 4   # 4-sample blending shoulder

out = ts_blend((hi, lo), blend_length=blend_length, names="blended")

# Weight given to the lower-priority series at each point
w_lo = ((out - hi) / (lo - hi)).where(hi.notna(), 1.0)
shoulder_mask = hi.notna() & (w_lo > 0)

fig, ax = plt.subplots(figsize=(10, 6))
ax.plot(hi.index, hi.values, "o-", label="High priority (hi)", linewidth=2)
ax.plot(lo.index, lo.values, "o--", label="Low priority (lo)", linewidth=2)
ax.plot(out.index, out.values, "o-", label="Blended output", linewidth=3)
ax.scatter(
    out.index[shoulder_mask],
    out.values[shoulder_mask],
    s=140,
    color="tab:red",
    label="Blended shoulder region",
    zorder=5,
)
ax.axvspan(idx[7], idx[9], color="grey", alpha=0.15, label="Gap in hi")
ax.set_title(f"Blending near a gap with ts_blend (blend_length={blend_length})")
ax.grid(alpha=0.3)
ax.legend()
fig.tight_layout()
plt.show()

pd.DataFrame({"hi": hi, "lo": lo, "blended": out, "w_lo": w_lo.round(2)})

../_images/notebooks_merge_splice_16_0.png
[8]:
hi lo blended w_lo
2023-01-01 5.000000 7.000000 5.000000 0.00
2023-01-02 5.981584 7.981584 5.981584 0.00
2023-01-03 6.855109 8.855109 6.855109 0.00
2023-01-04 7.524413 9.524413 7.524413 0.00
2023-01-05 7.915814 9.915814 8.415814 0.25
2023-01-06 7.986224 9.986224 8.986224 0.50
2023-01-07 7.727892 9.727892 9.227892 0.75
2023-01-08 NaN 9.169258 9.169258 1.00
2023-01-09 NaN 8.371818 8.371818 1.00
2023-01-10 NaN 7.423360 7.423360 1.00
2023-01-11 4.428296 6.428296 5.928296 0.75
2023-01-12 3.496169 5.496169 4.496169 0.50
2023-01-13 2.729593 4.729593 3.229593 0.25
2023-01-14 2.212956 4.212956 2.212956 0.00
2023-01-15 2.003135 4.003135 2.003135 0.00
2023-01-16 2.123227 4.123227 2.123227 0.00
2023-01-17 2.560012 4.560012 2.560012 0.00

The w_lo column shows the kernel: moving toward the gap the lower-priority weight is 0.25, 0.5, 0.75 and then 1.0 in the gap, so the output joins the lower-priority series without a step. The same works with a time-based blend_length on a regular index:

[9]:
# Time-based example with hourly data and blend_length="4h"
idx_h = pd.date_range("2023-02-01", periods=17, freq="h")
base_h = 5.0 + 3.0 * np.sin(np.arange(len(idx_h)) / 3.0)

hi_h = pd.Series(base_h, index=idx_h, name="hi_hourly")
hi_h.iloc[7:10] = np.nan
lo_h = pd.Series(base_h + 2.0, index=idx_h, name="lo_hourly")

out_h = ts_blend((hi_h, lo_h), blend_length="4h", names="blended")

w_lo_h = ((out_h - hi_h) / (lo_h - hi_h)).where(hi_h.notna(), 1.0)
shoulder_mask_h = hi_h.notna() & (w_lo_h > 0)

fig, ax = plt.subplots(figsize=(10, 5))
ax.plot(hi_h.index, hi_h.values, "o-", label="High priority (hi_hourly)", linewidth=2)
ax.plot(lo_h.index, lo_h.values, "o--", label="Low priority (lo_hourly)", linewidth=2)
ax.plot(out_h.index, out_h.values, "o-", label="Blended (4h window)", linewidth=3)
ax.scatter(
    out_h.index[shoulder_mask_h],
    out_h.values[shoulder_mask_h],
    s=140,
    color="tab:red",
    zorder=5,
    label="Blended shoulder region",
)
ax.axvspan(idx_h[7], idx_h[9], color="grey", alpha=0.15, label="Gap in hi")
ax.set_title("Hourly ts_blend with time-based blend_length='4h'")
ax.grid(alpha=0.3)
ax.legend()
fig.tight_layout()
plt.show()

pd.DataFrame({"hi_hourly": hi_h, "lo_hourly": lo_h, "blended": out_h, "w_lo": w_lo_h.round(2)})

../_images/notebooks_merge_splice_18_0.png
[9]:
hi_hourly lo_hourly blended w_lo
2023-02-01 00:00:00 5.000000 7.000000 5.000000 0.00
2023-02-01 01:00:00 5.981584 7.981584 5.981584 0.00
2023-02-01 02:00:00 6.855109 8.855109 6.855109 0.00
2023-02-01 03:00:00 7.524413 9.524413 7.524413 0.00
2023-02-01 04:00:00 7.915814 9.915814 8.415814 0.25
2023-02-01 05:00:00 7.986224 9.986224 8.986224 0.50
2023-02-01 06:00:00 7.727892 9.727892 9.227892 0.75
2023-02-01 07:00:00 NaN 9.169258 9.169258 1.00
2023-02-01 08:00:00 NaN 8.371818 8.371818 1.00
2023-02-01 09:00:00 NaN 7.423360 7.423360 1.00
2023-02-01 10:00:00 4.428296 6.428296 5.928296 0.75
2023-02-01 11:00:00 3.496169 5.496169 4.496169 0.50
2023-02-01 12:00:00 2.729593 4.729593 3.229593 0.25
2023-02-01 13:00:00 2.212956 4.212956 2.212956 0.00
2023-02-01 14:00:00 2.003135 4.003135 2.003135 0.00
2023-02-01 15:00:00 2.123227 4.123227 2.123227 0.00
2023-02-01 16:00:00 2.560012 4.560012 2.560012 0.00