I need required imputation in Python:
I tried using:
# Outlet_Size - Imputation - Its Not Running need to check Version 2.X
#Import mode function:
from scipy.stats import mode
#Determing the mode for each
outlet_size_mode = data.pivot_table(values='Outlet_Size',
columns='Outlet_Type',aggfunc=(lambda x:mode(x).mode[0]))
but I'm facing error while creating pivot table itself, I'm using Python 3.X latest version.
Looking for other options also?
I believe you can use Series.mode
and for select first value add Series.iat
:
outlet_size_mode = data.pivot_table(values='Outlet_Size',
columns='Outlet_Type',
aggfunc=lambda x: x.mode().iat[0])
print (outlet_size_mode)
Outlet_Type Supermarket_Type2 Supermarket_Typel
Outlet_Size Small Medium