Skip to content

Commit 17c6bc9

Browse files
committed
Add file
1 parent d4f2b3c commit 17c6bc9

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
"""
2+
2887. Fill Missing Data
3+
Solved
4+
Easy
5+
Companies
6+
Hint
7+
8+
DataFrame products
9+
+-------------+--------+
10+
| Column Name | Type |
11+
+-------------+--------+
12+
| name | object |
13+
| quantity | int |
14+
| price | int |
15+
+-------------+--------+
16+
17+
Write a solution to fill in the missing value as 0 in the quantity column.
18+
19+
The result format is in the following example.
20+
21+
Example 1:
22+
Input:+-----------------+----------+-------+
23+
| name | quantity | price |
24+
+-----------------+----------+-------+
25+
| Wristwatch | None | 135 |
26+
| WirelessEarbuds | None | 821 |
27+
| GolfClubs | 779 | 9319 |
28+
| Printer | 849 | 3051 |
29+
+-----------------+----------+-------+
30+
Output:
31+
+-----------------+----------+-------+
32+
| name | quantity | price |
33+
+-----------------+----------+-------+
34+
| Wristwatch | 0 | 135 |
35+
| WirelessEarbuds | 0 | 821 |
36+
| GolfClubs | 779 | 9319 |
37+
| Printer | 849 | 3051 |
38+
+-----------------+----------+-------+
39+
Explanation:
40+
The quantity for Wristwatch and WirelessEarbuds are filled by 0.
41+
"""
42+
43+
import pandas as pd
44+
45+
def fillMissingValues(products: pd.DataFrame) -> pd.DataFrame:
46+
products['quantity'].fillna(0, inplace=True)
47+
return products

0 commit comments

Comments
 (0)