擅长:python、mysql、java
<p>首先,以12分钟的频率构建DateTimeIndex:</p>
<pre><code>import datetime
import pandas as pd
import numpy as np
start = datetime.datetime(2014, 4, 2)
end = datetime.datetime(2014, 8, 1) # whenever your time series ends
idx = pd.date_range(start, end, freq='12T') # 12T = 12 minutes
</code></pre>
<p>接下来,您必须使用新索引构建数据帧:</p>
<pre><code>df = pd.DataFrame(np.nan, index=idx, columns=['dummy']) # you need to provide a column name
</code></pre>
<p>我想,您的数据是在一个带有DateTimeIndex的pd.Series<code>s</code>中,否则您必须构建一个</p>
<p>现在,您可以使用DateTimeIndex和pandas的全部功能:</p>
<pre><code>df['Rain_Rate'] = s
df['Rain_Rate'] = df['Rain_Rate'].interpolate() # standard is linear approximation
</code></pre>
<p>查看<a href="https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.interpolate.html" rel="nofollow noreferrer">interpolate()</a>了解更多选项</p>