擅长:python、mysql、java
<h2>选项1</h2>
<pre><code>df.loc[df.index[0] - pd.offsets.Minute(30), 'value'] = 2
df = df.sort_index()
df
value
index
2014-05-21 09:30:00 2.0
2014-05-21 10:00:00 13.0
2014-05-21 10:30:00 8.0
2014-05-21 11:00:00 9.0
2014-05-21 11:30:00 7.0
2014-05-21 12:00:00 2.0
</code></pre>
<hr/>
<h2>方案2</h2>
<p>设置索引的频率,以便可以自然递减。<br/>
这是来自@root<a href="https://stackoverflow.com/a/40223868/2336654">HERE</a>的回答</p>
^{pr2}$