Select rows from a DataFrame based on a single float column values

Viewed 26

I have a data frame as shown below.I need to select all rows for which the value of first column named index is less than 0.3768.

I have found some answers in stack over flow,but none of them is working in my case enter image description here

I tried to create a data frame which contains all rows where the column(named index as shown in yellow) value .Below is my code it is throwing some error.May I know where I went wrong.

df2 = df_thd_funct_mode2_perf['index'] <= 0.3768
df2

The error obtained is given below.

'<=' not supported between instances of 'str' and 'float'

1 Answers

You're looking for:

df2 = df_thd_funct_mode2_perf[df_thd_funct_mode2_perf['index'] <= 0.3768]

A short explanation:

We're saying here: Take all of the rows and columns of df_thd_funct_mode2_perf for which [df_thd_funct_mode2_perf['index'] <= 0.3768] and then save this to df2

Related