调试中...
调试中...
题目描述
题目描述
题解
题解
提交记录
提交记录
代码
代码
测试用例
测试用例
测试结果
测试结果
简单
相关企业
提示
DataFrame products
+-------------+--------+
| Column Name | Type   |
+-------------+--------+
| name        | object |
| quantity    | int    |
| price       | int    |
+-------------+--------+

编写一个解决方案,在 quantity 列中将缺失的值填充为 0

返回结果如下示例所示。

 

示例 1:
输入:
+-----------------+----------+-------+
| name            | quantity | price |
+-----------------+----------+-------+
| Wristwatch      | 32       | 135   |
| WirelessEarbuds | None     | 821   |
| GolfClubs       | None     | 9319  |
| Printer         | 849      | 3051  |
+-----------------+----------+-------+
输出:
+-----------------+----------+-------+
| name            | quantity | price |
+-----------------+----------+-------+
| Wristwatch      | 32       | 135   |
| WirelessEarbuds | 0        | 821   |
| GolfClubs       | 0        | 9319  |
| Printer         | 849      | 3051  |
+-----------------+----------+-------+
解释:
Toaster 和 Headphones 的数量被填充为 0。
通过次数
4.9K
提交次数
6.9K
通过率
71.4%

相关企业

提示 1
Consider using a build-in function in pandas library to fill the missing values of specified columns.

评论 (0)

贡献者
© 2025 领扣网络(上海)有限公司
0 人在线
行 1,列 1
运行和提交代码需要登录
products =
| name | quantity | price | | --------------- | -------- | ----- | | Wristwatch | null | 135 | | WirelessEarbuds | null | 821 | | GolfClubs | 779 | 9319 | | Printer | 849 | 3051 |