TypeError: '<' not supported between instances of 'int' and 'str' I have the following code
rf = RandomForestClassifier()
rf.fit(X_train, Y_train)
print(&quot;Features sorted by their score:&quot;)
print(sorted(zip(map(lambda x: round(x, 2), rf.feature_importances_), X_train), reverse=True))

and I get the following error:
&gt; TypeError Traceback (most recent call last)
&gt;
&gt; ipython-input-109-c48c3ffd74e2&gt; in &lt;module&gt;()
&gt; 
&gt; 2 rf.fit(X_train, Y_train)
&gt; 
&gt; 3 print (&quot;Features sorted by their score:&quot;)
&gt; 
&gt; ----&gt; 4 print (sorted(zip(map(lambda x: round(x, 2),
&gt; rf.feature_importances_), X_train), reverse=True))
&gt; 
&gt; TypeError: '&lt;' not supported between instances of 'int' and 'str'

I am not sure what I am doing wrong. I only have int and float in my dataframe.
Based on our discussion, omit reverse = True and use list instead of sorted and print it. I guess you will see what you want.