Last active
January 24, 2016 07:57
-
-
Save mrahul17/ff33bbbd7970988372d0 to your computer and use it in GitHub Desktop.
Pandas utility scripts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#check if na values exist at all | |
df.isnull().any().any() | |
#if above returns true for any series | |
df.isnull().any() | |
#check for NA values | |
data.isnull().sum() | |
#replace NA values | |
# for real values | |
data['series_to_replace'] = data['series_to_replace'].fillna(data.mean()['series_to_replace']) | |
# convert string to int | |
mapping = {string:int} | |
data.replace({'column_name':mapping}) | |
#find number of unique items in a series | |
data['series_name'].nunique() | |
#find uniquevalues | |
pd.unique(data['column_name']) | |
#this http://stackoverflow.com/questions/17995328/changing-values-in-pandas-dataframe-doenst-work |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment