擅长:python、mysql、java
<p>使用<code>reindex</code></p>
<pre><code>In [350]: df
Out[350]:
a
N0000 1
N0002 2
N0003 3
N0007 4
In [358]: df.reindex(['N%04d' % x for x in range(int(df.index[-1][1:])+1)])
Out[358]:
a
N0000 1.0
N0001 NaN
N0002 2.0
N0003 3.0
N0004 NaN
N0005 NaN
N0006 NaN
N0007 4.0
</code></pre>