1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-25 17:50:26 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/填充缺失值 [fill-missing-data].html

40 lines
1.2 KiB
HTML
Raw Normal View History

2023-12-09 18:53:53 +08:00
<pre>
DataFrame <code>products</code>
+-------------+--------+
| Column Name | Type |
+-------------+--------+
| name | object |
| quantity | int |
| price | int |
+-------------+--------+
</pre>
<p>编写一个解决方案,在 <code>quantity</code> 列中将缺失的值填充为&nbsp;<code><strong>0</strong></code></p>
<p>返回结果如下示例所示。</p>
<p>&nbsp;</p>
<strong class="example">示例 1</strong>
<pre>
<strong>输入:
</strong>+-----------------+----------+-------+
| name | quantity | price |
+-----------------+----------+-------+
| Wristwatch | 32 | 135 |
| WirelessEarbuds | None | 821 |
| GolfClubs | None | 9319 |
| Printer | 849 | 3051 |
+-----------------+----------+-------+
<strong>输出:
</strong>+-----------------+----------+-------+
| name | quantity | price |
+-----------------+----------+-------+
| Wristwatch | 32 | 135 |
| WirelessEarbuds | 0 | 821 |
| GolfClubs | 0 | 9319 |
| Printer | 849 | 3051 |
+-----------------+----------+-------+
<b>解释:</b>
Toaster 和 Headphones 的数量被填充为 0。</pre>