Skip to content

Instantly share code, notes, and snippets.

View ppeiris's full-sized avatar
🏋️‍♂️
Working on machine learning projects

Prabath Peiris ppeiris

🏋️‍♂️
Working on machine learning projects
View GitHub Profile
@ppeiris
ppeiris / useful_pandas_snippets.py
Created February 9, 2016 19:53 — forked from bsweger/useful_pandas_snippets.md
Useful Pandas Snippets
#List unique values in a DataFrame column
pd.unique(df.column_name.ravel())
#Convert Series datatype to numeric, getting rid of any non-numeric values
df['col'] = df['col'].astype(str).convert_objects(convert_numeric=True)
#Grab DataFrame rows where column has certain values
valuelist = ['value1', 'value2', 'value3']
df = df[df.column.isin(value_list)]