<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Title
Step1:  Create dataframe with missing values
Step2:  Drop missing observations
Step3:  Drop rows where all cells in that row is NA
Step4:  Create a new column full of missing values
Step5:  Drop column if they only contain missing values
Step6:  Drop rows that contain less than five observations
This is really mostly useful for time series
Step7:  Fill in missing data with zeros
Step8:  Fill in missing in preTestScore with the mean value of preTestScore
inplace=True means that the changes are saved to the df right away
Step9:  Fill in missing in postTestScore with each sex's mean value of postTestScore
Step10:  Select some raws but ignore the missing data points
<ASSISTANT_TASK:>
Python Code:
import pandas as pd
import numpy as np
Explanation: Title: Missing Data In Pandas Dataframes
Slug: pandas_missing_data
Summary: Missing Data In Pandas Dataframes
Date: 2016-05-01 12:00
Category: Python
Tags: Data Wrangling
Authors: Chris Albon  
import modules
End of explanation
raw_data = {'first_name': ['Jason', np.nan, 'Tina', 'Jake', 'Amy'], 
        'last_name': ['Miller', np.nan, 'Ali', 'Milner', 'Cooze'], 
        'age': [42, np.nan, 36, 24, 73], 
        'sex': ['m', np.nan, 'f', 'm', 'f'], 
        'preTestScore': [4, np.nan, np.nan, 2, 3],
        'postTestScore': [25, np.nan, np.nan, 62, 70]}
df = pd.DataFrame(raw_data, columns = ['first_name', 'last_name', 'age', 'sex', 'preTestScore', 'postTestScore'])
df
Explanation: Create dataframe with missing values
End of explanation
df_no_missing = df.dropna()
df_no_missing
Explanation: Drop missing observations
End of explanation
df_cleaned = df.dropna(how='all')
df_cleaned
Explanation: Drop rows where all cells in that row is NA
End of explanation
df['location'] = np.nan
df
Explanation: Create a new column full of missing values
End of explanation
df.dropna(axis=1, how='all')
Explanation: Drop column if they only contain missing values
End of explanation
df.dropna(thresh=5)
Explanation: Drop rows that contain less than five observations
This is really mostly useful for time series
End of explanation
df.fillna(0)
Explanation: Fill in missing data with zeros
End of explanation
df["preTestScore"].fillna(df["preTestScore"].mean(), inplace=True)
df
Explanation: Fill in missing in preTestScore with the mean value of preTestScore
inplace=True means that the changes are saved to the df right away
End of explanation
df["postTestScore"].fillna(df.groupby("sex")["postTestScore"].transform("mean"), inplace=True)
df
Explanation: Fill in missing in postTestScore with each sex's mean value of postTestScore
End of explanation
# Select the rows of df where age is not NaN and sex is not NaN
df[df['age'].notnull() & df['sex'].notnull()]
Explanation: Select some raws but ignore the missing data points
End of explanation
<END_TASK>