Skip to content

Instantly share code, notes, and snippets.

View oserttas-math's full-sized avatar
🏠
Working from home

ozkan serttas oserttas-math

🏠
Working from home
View GitHub Profile
@oserttas-math
oserttas-math / README.md
Created July 15, 2018 17:16 — forked from hofmannsven/README.md
My simply Git Cheatsheet
@oserttas-math
oserttas-math / pandas-dummy-variables.txt
Created June 11, 2018 17:00 — forked from sethbunke/pandas-dummy-variables.txt
Simple example of creating dummy variables using Python Pandas
#import pandas and numpy
import pandas as pd
import numpy as np
#create dataframe with some random data
df = pd.DataFrame(np.random.rand(10, 2) * 10, columns=['Price', 'Qty'])
#add a column with random string values that would need to have dummy variables created for them
df['City'] = [np.random.choice(('Chicago', 'Boston', 'New York')) for i in range(df.shape[0])]
@oserttas-math
oserttas-math / useful_pandas_snippets.py
Created December 16, 2017 03:20 — forked from bsweger/useful_pandas_snippets.md
Useful Pandas Snippets
# List unique values in a DataFrame column
# h/t @makmanalp for the updated syntax!
df['Column Name'].unique()
# Convert Series datatype to numeric (will error if column has non-numeric values)
# h/t @makmanalp
pd.to_numeric(df['Column Name'])
# Convert Series datatype to numeric, changing non-numeric values to NaN
# h/t @makmanalp for the updated syntax!