Drop Missing Data — LeetCode 2883 Python Solution
EasyPandas
- Problem
- #2883
- Reading time
- 2 min
- Source
- leetcode.com
Table schema
SQL
DataFrame students +-------------+--------+ | Column Name | Type | +-------------+--------+ | student_id | int | | name | object | | age | int | +-------------+--------+ There are some rows having missing values in the name column. Write a solution to remove the rows with missing values.Example
SQL
DataFrame students
+-------------+--------+
| Column Name | Type |
+-------------+--------+
| student_id | int |
| name | object |
| age | int |
+-------------+--------+Python solution
Python
import pandas as pd
def dropMissingData(students: pd.DataFrame) -> pd.DataFrame:
return students[students['name'].notnull()]Complexity
| Measure | Complexity |
|---|---|
| Time | O(n) |
| Space | O(1) to O(n) auxiliary |
Related problems
Frequently asked questions
- How hard is LeetCode 2883. Drop Missing Data?
- LeetCode 2883. Drop Missing Data is rated Easy on LeetCode.
- What topics does LeetCode 2883. Drop Missing Data cover?
- LeetCode 2883. Drop Missing Data is tagged Pandas on LeetCode.