擅长:python、mysql、java
<p>这实际上取决于您试图解决的问题,但通常使用的方法是<code>bfill()</code>或<code>ffill()</code>:</p>
<pre><code>df.ffill()
Year GarageArea GarageCars
1 1900.0 10 1
2 1900.0 0 0
3 2001.0 50 2
4 1950.0 70 2
5 2019.0 100 4
df.bfill()
Year GarageArea GarageCars
1 1900.0 10 1
2 2001.0 0 0
3 2001.0 50 2
4 1950.0 70 2
5 2019.0 100 4
</code></pre>