le = LabelEncoder()
ds = df.apply(le.fit_transform)
I have written the same as told by sir but it is showing the error.
le = LabelEncoder()
ds = df.apply(le.fit_transform)
I have written the same as told by sir but it is showing the error.
Following is showing:
TypeError Traceback (most recent call last)
~\anaconda3\lib\site-packages\sklearn\preprocessing_label.py in _encode(values, uniques, encode, check_unknown)
111 try:
–> 112 res = _encode_python(values, uniques, encode)
113 except TypeError:
~\anaconda3\lib\site-packages\sklearn\preprocessing_label.py in _encode_python(values, uniques, encode)
59 if uniques is None:
—> 60 uniques = sorted(set(values))
61 uniques = np.array(uniques, dtype=values.dtype)
TypeError: ‘<’ not supported between instances of ‘str’ and ‘float’
During handling of the above exception, another exception occurred:
TypeError Traceback (most recent call last)
in
1 le = LabelEncoder()
----> 2 ds = df.apply(le.fit_transform)
~\anaconda3\lib\site-packages\pandas\core\frame.py in apply(self, func, axis, raw, result_type, args, **kwds)
6876 kwds=kwds,
6877 )
-> 6878 return op.get_result()
6879
6880 def applymap(self, func) -> “DataFrame”:
~\anaconda3\lib\site-packages\pandas\core\apply.py in get_result(self)
184 return self.apply_raw()
185
–> 186 return self.apply_standard()
187
188 def apply_empty_result(self):
~\anaconda3\lib\site-packages\pandas\core\apply.py in apply_standard(self)
311
312 # compute the result using the series generator
–> 313 results, res_index = self.apply_series_generator()
314
315 # wrap results
~\anaconda3\lib\site-packages\pandas\core\apply.py in apply_series_generator(self)
339 else:
340 for i, v in enumerate(series_gen):
–> 341 results[i] = self.f(v)
342 keys.append(v.name)
343
~\anaconda3\lib\site-packages\sklearn\preprocessing_label.py in fit_transform(self, y)
250 “”"
251 y = column_or_1d(y, warn=True)
–> 252 self.classes_, y = _encode(y, encode=True)
253 return y
254
~\anaconda3\lib\site-packages\sklearn\preprocessing_label.py in _encode(values, uniques, encode, check_unknown)
112 res = _encode_python(values, uniques, encode)
113 except TypeError:
–> 114 raise TypeError(“argument must be a string or number”)
115 return res
116 else:
TypeError: argument must be a string or number
Still giving the error
hey @Ankit003 ,
can you please provide me link to your notebook along with dataset.
As i tried with the mushroom dataset and it worked.
How to do provide link?
file:///C:/Users/ankit/Desktop/Machine%20Learning/Bayes%20theorem.ipynb
hey @Ankit003 ,
just upload all the files to your google drive and share them with me at [email protected].
and send the link here.
Yes sir, i have provided
hey @Ankit003,
there is some error in your notebook.
its not able to get load on my system .
So one thing , upload your notebook on github and share me its link. and do confirm before sharing that you are able to view your notebook on github properly.
That would be much better.
Thank You