This file contains 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
import pandas as pd | |
from sklearn.preprocessing import LabelEncoder,OneHotEncoder | |
def decode_encode(colname): | |
''' | |
(str) -> (DataFrame) | |
Returns a Data Frame with the column given to it transformed into a One-hot encoded set of columns |
This file contains 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
import pandas as pd | |
from scipy.stats import mode | |
grouped_mod = df.pivot_table(values='The metric you need the mode for',columns='Category',aggfunc=mode) |