Skip to content

Instantly share code, notes, and snippets.

@hernamesbarbara
Created October 31, 2012 15:42
Show Gist options
  • Save hernamesbarbara/3987749 to your computer and use it in GitHub Desktop.
Save hernamesbarbara/3987749 to your computer and use it in GitHub Desktop.
handle NA values in pandas
#/usr/bin/env python
# Handling NA values in pandas
import pandas as pd
# replace all NA values with your own missing value
my_data_frame['my_column'].fillna('MY_MISSING_VAL')
# return a subset of your dataframe
records = pd.Series([rec for rec in df.my_column.dropna()])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment