Skip to content

Commit 3069318

Browse files
committed
Add file
1 parent 6a9a219 commit 3069318

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+
2883. Drop Missing Data
3+
Solved
4+
Easy
5+
Companies
6+
Hint
7+
DataFrame students
8+
+-------------+--------+
9+
| Column Name | Type |
10+
+-------------+--------+
11+
| student_id | int |
12+
| name | object |
13+
| age | int |
14+
+-------------+--------+
15+
There are some rows having missing values in the name column.
16+
17+
Write a solution to remove the rows with missing values.
18+
19+
The result format is in the following example.
20+
21+
Example 1:
22+
23+
Input:
24+
+------------+---------+-----+
25+
| student_id | name | age |
26+
+------------+---------+-----+
27+
| 32 | Piper | 5 |
28+
| 217 | None | 19 |
29+
| 779 | Georgia | 20 |
30+
| 849 | Willow | 14 |
31+
+------------+---------+-----+
32+
Output:
33+
+------------+---------+-----+
34+
| student_id | name | age |
35+
+------------+---------+-----+
36+
| 32 | Piper | 5 |
37+
| 779 | Georgia | 20 |
38+
| 849 | Willow | 14 |
39+
+------------+---------+-----+
40+
Explanation:
41+
Student with id 217 havs empty value in the name column, so it will be removed."
42+
"""
43+
44+
import pandas as pd
45+
46+
def dropMissingData(students: pd.DataFrame) -> pd.DataFrame:
47+
return students.dropna(subset="name")

0 commit comments

Comments
 (0)