Error encountered while executing Mode calculation in Big Mart Sales prediction problem

Hi I am facing associated problem - getting following error wen calculating the mode of outlet size against Outlet type. I am following

Approach and Solution to break in Top 20 of Big Mart Sales prediction - hosted on AV portal.

Code:
outlet_size_mode = data.pivot_table(values=‘Outlet_Size’, columns=‘Outlet_Type’,aggfunc=(lambda x:mode(x).mode[0]))

Error:
TypeError: ‘<’ not supported between instances of ‘str’ and ‘float’

Error is happening in uniqueID module of ‘Mode’

I noticed that this problem is encountering due to presence of NaN in Outlet_size col. now if i replace NaN with sm other value, then it changes the ‘mode’ calculations , specially for Outlet_Type - Grocery.
Please help.

Replace NaN with a random number, say 999. It won’t affect the Mode value.