1

I have a variable called 'Biovolumes_vivo' type float64. I want to filter and remove the values higher than 8192.

I've done some research and I found something similar here: Pandas How to filter a Series

I modified the script according to my data:

Biovolumes_vivo = Biovolumes_vivo[Biovolumes_vivo !< 8192]

However, it says 'invalid syntax'.

I guees there is something wrong with '!<'. Thanks in advance for the help

EdChum
  • 376,765
  • 198
  • 813
  • 562
Olga
  • 65
  • 2
  • 10

2 Answers2

4

!< is invalid you want

Biovolumes_vivo = Biovolumes_vivo[Biovolumes_vivo < 8192]

the valid operators here are <, >, ==, !=, <=, >= for comparison there are also pandas equivalents such as:

Biovolumes_vivo = Biovolumes_vivo[Biovolumes_vivo.lt(8192)]

which is lt which means less than

EdChum
  • 376,765
  • 198
  • 813
  • 562
0
Biovolumes_vivo = Biovolumes_vivo[Biovolumes_vivo !< 8192]

Is not a valid syntax. If you want to perform a conditional test that is lower than 8192 you would need to use the < operator. If !< means not lower than, you will want to use the > than operator instead. Here is an example:

Biovolumes_vivo = Biovolumes_vivo[Biovolumes_vivo > 8192]

As you know, this will return a df of the values that are true in pandas.

Simeon Ikudabo
  • 2,152
  • 1
  • 10
  • 27