Please note, this is a STATIC archive of website www.w3resource.com from 19 Jul 2022, cach3.com does not collect or store any user information, there is no "phishing" involved.

Examples
A series with 4 one minute timestamps:

In [1]:
import numpy as np
import pandas as pd
In [2]:
index = pd.date_range('1/1/2019', periods=4, freq='T')
series = pd.Series([0.0, None, 4.0, 5.0], index=index)
df = pd.DataFrame({'s':series})
df
Out[2]:
s
2019-01-01 00:00:00 0.0
2019-01-01 00:01:00 NaN
2019-01-01 00:02:00 4.0
2019-01-01 00:03:00 5.0

Upsample the series into 30 second bins:

In [3]:
df.asfreq(freq='30S')
Out[3]:
s
2019-01-01 00:00:00 0.0
2019-01-01 00:00:30 NaN
2019-01-01 00:01:00 NaN
2019-01-01 00:01:30 NaN
2019-01-01 00:02:00 4.0
2019-01-01 00:02:30 NaN
2019-01-01 00:03:00 5.0

Upsample again, providing a fill value:

In [4]:
df.asfreq(freq='30S', fill_value=7.0)
Out[4]:
s
2019-01-01 00:00:00 0.0
2019-01-01 00:00:30 7.0
2019-01-01 00:01:00 NaN
2019-01-01 00:01:30 7.0
2019-01-01 00:02:00 4.0
2019-01-01 00:02:30 7.0
2019-01-01 00:03:00 5.0

Upsample again, providing a method:

In [5]:
df.asfreq(freq='30S', method='bfill')
Out[5]:
s
2019-01-01 00:00:00 0.0
2019-01-01 00:00:30 NaN
2019-01-01 00:01:00 NaN
2019-01-01 00:01:30 4.0
2019-01-01 00:02:00 4.0
2019-01-01 00:02:30 5.0
2019-01-01 00:03:00 5.0