Reputation: 21
the code is
import scipy.stats as stats
stats.mode(df['Gender']')
three are some null in df['Gender'],and the problem is 'TypeError: unorderable types: str() > float()'.[scipy(0.19.1) python3.5.2] How? please,THx.
Upvotes: 1
Views: 376
Reputation: 7957
As you said the error arises because there are missing values in your data. I am assuming you are using pandas dataframe. To take the mode, you can omit the rows which have missing values.
stats.mode(df.loc[~(df['G'].isnull()),'G'])
Upvotes: 2