The only thing I can see wrong with the code you have is that
item
is a string and you must first convert it to a numeric type. As the error message says
Quote:
'<=' not supported between instances of 'str' and 'float'
then I suggest you convert it to a float, although interestingly there is no
<=
in the code you shared, so that cannot be the error message you received.
You could try something like this
for item in dataframe:
if float(item) > 100:
...
or you could convert the entire column of the dataframe to be float (or integer) - probably the best option if you want to reset the values to a numeric - see
Pandas Convert Column to Float in DataFrame - Spark by {Examples}[
^]
I have just seen the following comment in the documentation for pandas Dataframe
Quote:
You should never modify something you are iterating over. This is not guaranteed to work in all cases. Depending on the data types, the iterator returns a copy and not a view, and writing to it will have no effect.
You are going to have to find an alternative way to achieve whatever it is you are trying to do - perhaps at the point of populating the datafram