Skip to content

Commit 8e3dc01

Browse files
committed
post-TR1 Update attempt 1
1 parent 20a4c37 commit 8e3dc01

File tree

4 files changed

+10
-6
lines changed

4 files changed

+10
-6
lines changed

how-to-drop-null-values-in-pandas/drop_a_subset.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import pandas as pd
22

3+
4+
pd.set_option("display.max_columns", None)
5+
36
sales_data = pd.read_csv(
47
"sales_data_with_missing_values.csv",
58
parse_dates=["order_date"],

how-to-drop-null-values-in-pandas/drop_null_columns.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import pandas as pd
22

3+
34
sales_data = pd.read_csv(
45
"sales_data_with_missing_values.csv",
56
parse_dates=["order_date"],

how-to-drop-null-values-in-pandas/drop_null_rows.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import pandas as pd
22

3+
pd.set_option("display.max_columns", None)
4+
35
sales_data = pd.read_csv(
46
"sales_data_with_missing_values.csv",
57
parse_dates=["order_date"],
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
import pandas as pd
2-
31
grades = pd.read_csv(
42
"grades.csv",
53
).convert_dtypes(dtype_backend="pyarrow")
64

7-
# 1. Permanently drop the last row of the dataframe.
5+
# 1. Use `.dropna()` in such a way that it permanently drops the row in the dataframe containing only null values.
86

97
grades.dropna(how="all", inplace=True)
108

@@ -16,10 +14,10 @@
1614

1715
grades.dropna(axis=1)
1816

19-
# 4. Display the exams students have sat five or more times.
17+
# 4. Display the exams sat by at least five students.
2018

21-
grades.dropna(axis=0, thresh=6) # Remember there are seven columns.
19+
grades.dropna(axis=0, thresh=6) # Remember there are seven columns.
2220

23-
# 5. Who else would be in the exam hall when both `S2` and `S4` were there?
21+
# 5. Who else was in in every exam that both S2 and S4 sat?
2422

2523
grades.dropna(subset=["S2", "S4"]).dropna(axis=1, ignore_index=True)

0 commit comments

Comments
 (0)