I am trying to filter the rows of a data frame where the last column is less than 4, without specifying the column name. [See this question for context on data frame] (Convert the last column of a data frame from hex to decimal)
I used the solution provided by @not_speshal but I am getting this error. TypeError: '>=' not supported between instances of 'str' and 'int'. How can I fix it?
The solution is wrong. When you use this one:
df[df.columns[-2]<=4]
What you do is to compare the name of the column at index -2 with 4. Like "Color" > 4, which gives an error. Try this one:
df[df[df.columns[-2]]<=4]
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments