1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-10 18:48:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/填充缺失值 [fill-missing-data].html
2023-12-09 18:53:53 +08:00

40 lines
1.2 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<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>