Problem 1

Import NumPy under the alias np.

In [1]:
import numpy as np

Problem 2

Import pandas under the alias pd.

In [2]:
import pandas as pd

Problem 3

Given the DataFrame data, remove all of its rows that contain null values using the pandas method discussed in the lesson.

In [3]:
data = pd.DataFrame(np.array([[np.nan, 8, 12],[np.nan, 16, np.nan],[4, 13, 45]]))
In [4]:
#Solution goes here
data.dropna()
Out[4]:
0 1 2
2 4.0 13.0 45.0

Problem 4

Given the DataFrame data, remove all of its columns that contain null values using the pandas method discussed in the lesson.

In [5]:
#Solution goes here
data.dropna(axis=1)
Out[5]:
1
0 8.0
1 16.0
2 13.0

Problem 5

Given the DataFrame data, replace all of its null values with 💩 (copy and paste it).

In [6]:
data.fillna('💩')
Out[6]:
0 1 2
0 💩 8.0 12
1 💩 16.0 💩
2 4 13.0 45

Problem 6

Given the DataFrame data, replace all of its null values with the mean value across the entire DataFrame.

In [7]:
data.fillna(data.mean())
Out[7]:
0 1 2
0 4.0 8.0 12.0
1 4.0 16.0 28.5
2 4.0 13.0 45.0