Skip to main content
Post Closed as "Duplicate" by Trenton McKinney pandas
added 307 characters in body
Source Link
Confused
  • 353
  • 3
  • 8
  • 22

I am new to Python. I have a data frame as shown below. This is a CSV file. I need to select all rows which contain Frequency values 0.8 and 0.6. I wrote the codes as shown but it is throwing an error.

df_new = df[df['Frequency'] == 0.8 & df['Frequency'] == 1.6 ]

Below is the last line from the error I received.

"TypeError: Cannot perform 'rand_' with a dtyped [float64] array and scalar of type [bool]"

I ran the below code

df_new = df[(df['Frequency'] == 0.8) & (df['Frequency'] == 1.6) ]

It is nt showing any error but values are not coming.it is showing only the name of columns .Please see the bwloe image

enter image description here

enter image description here

I am new to Python. I have a data frame as shown below. This is a CSV file. I need to select all rows which contain Frequency values 0.8 and 0.6. I wrote the codes as shown but it is throwing an error.

df_new = df[df['Frequency'] == 0.8 & df['Frequency'] == 1.6 ]

Below is the last line from the error I received.

"TypeError: Cannot perform 'rand_' with a dtyped [float64] array and scalar of type [bool]"

enter image description here

I am new to Python. I have a data frame as shown below. This is a CSV file. I need to select all rows which contain Frequency values 0.8 and 0.6. I wrote the codes as shown but it is throwing an error.

df_new = df[df['Frequency'] == 0.8 & df['Frequency'] == 1.6 ]

Below is the last line from the error I received.

"TypeError: Cannot perform 'rand_' with a dtyped [float64] array and scalar of type [bool]"

I ran the below code

df_new = df[(df['Frequency'] == 0.8) & (df['Frequency'] == 1.6) ]

It is nt showing any error but values are not coming.it is showing only the name of columns .Please see the bwloe image

enter image description here

enter image description here

Source Link
Confused
  • 353
  • 3
  • 8
  • 22

Pandas_select rows from a dataframe based on column values

I am new to Python. I have a data frame as shown below. This is a CSV file. I need to select all rows which contain Frequency values 0.8 and 0.6. I wrote the codes as shown but it is throwing an error.

df_new = df[df['Frequency'] == 0.8 & df['Frequency'] == 1.6 ]

Below is the last line from the error I received.

"TypeError: Cannot perform 'rand_' with a dtyped [float64] array and scalar of type [bool]"

enter image description here