12 Useful Pandas Techniques in Python for Data Manipulation error in filling missing values

in case of technique#3, while executing following code i am getting error, how do i rectify it

import pandas as pd
import numpy as np
import matplotlib as plt
df=pd.read_csv("/Users/choudharyshubham6789/ANALYTICS VIDHYA/train.csv")
from scipy.stats import mode
df['Gender'].fillna(mode(df['Gender']).mode[0], inplace=True)
df['Married'].fillna(mode(df['Married']).mode[0], inplace=True)
df['Self_Employed'].fillna(mode(df['Self_Employed']).mode[0], inplace=True)
def mn(x):
       return sum(x.isnull())
print("the missing values in column are:")
print(df.apply(mn, axis=0))
print("\n the missing values in column are:")
print(df.apply(mn, axis=1))

the error is

C:\ProgramData\Anaconda3\lib\site-packages\scipy\stats\stats.py:245: RuntimeWarning: The input array could not be properly checked for nan values. nan values will be ignored.
  "values. nan values will be ignored.", RuntimeWarning)
TypeError                                 Traceback (most recent call last)
<ipython-input-20-7710b3b5f55e> in <module>()
     10 #print(df.apply(mn, axis=1))
     11 from scipy.stats import mode
---> 12 df['Gender'].fillna(mode(df['Gender']).mode[0], inplace=True)
     13 df['Married'].fillna(mode(df['Married']).mode[0], inplace=True)
     14 df['Self_Employed'].fillna(mode(df['Self_Employed']).mode[0], inplace=True)

C:\ProgramData\Anaconda3\lib\site-packages\scipy\stats\stats.py in mode(a, axis, nan_policy)
    437         return mstats_basic.mode(a, axis)
--> 439     scores = np.unique(np.ravel(a))       # get ALL unique values
    440     testshape = list(a.shape)
    441     testshape[axis] = 1

C:\ProgramData\Anaconda3\lib\site-packages\numpy\lib\arraysetops.py in unique(ar, return_index, return_inverse, return_counts, axis)
    221     ar = np.asanyarray(ar)
    222     if axis is None:
--> 223         return _unique1d(ar, return_index, return_inverse, return_counts)
    224     if not (-ar.ndim <= axis < ar.ndim):
    225         raise ValueError('Invalid axis kwarg specified for unique')

C:\ProgramData\Anaconda3\lib\site-packages\numpy\lib\arraysetops.py in _unique1d(ar, return_index, return_inverse, return_counts)
    281         aux = ar[perm]
    282     else:
--> 283         ar.sort()
    284         aux = ar
    285     flag = np.concatenate(([True], aux[1:] != aux[:-1]))

TypeError: '<' not supported between instances of 'str' and 'float'
© Copyright 2013-2019 Analytics Vidhya