Quantcast
Channel: Data Science, Analytics and Big Data discussions - Latest topics
Viewing all articles
Browse latest Browse all 4448

Question about 'A Complete Tutorial to Learn Data Science with Python from Scratch'

$
0
0

@melkote wrote:

When I enter the following code from the tutorial:
from sklearn.preprocessing import LabelEncoder
var_mod = [‘Gender’,‘Married’,‘Dependents’,‘Education’,‘Self_Employed’,‘Property_Area’,‘Loan_Status’]
le = LabelEncoder()
for i in var_mod:
df[i] = le.fit_transform(df[i])
df.dtypes

I get the error below. Can someone please advise? Thank you!

In [24]: for i in var_mod:
…: df[i] = le.fit_transform(df[i])
…:
…:
Traceback (most recent call last):

File “”, line 2, in
df[i] = le.fit_transform(df[i])

File “C:\ProgramData\Anaconda3\lib\site-packages\sklearn\preprocessing\label.py”, line 131, in fit_transform
self.classes_, y = np.unique(y, return_inverse=True)

File “C:\ProgramData\Anaconda3\lib\site-packages\numpy\lib\arraysetops.py”, line 195, in unique
perm = ar.argsort(kind=‘mergesort’ if return_index else ‘quicksort’)

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

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 4448

Trending Articles