Back to Community
help --- Fundamentals.country_id =="USA"
API

Hi all

When I used Fundamentals.country_id =="USA", i got this error:

TypeError: ufunc 'isnan' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''

same error for --- Fundamentals.is_primary_share == 1
Can anyone help me to solve this? Thanks.

1 response

There are only a limited number of methods and operands that are defined for factors and classifiers. The '==' operand is not one of them. To create a filter for all securities with a country_id of 'USA' use the .eq method. Alternately, if one wants to check if a value is in a list (eg either USA or GBR) then one can use the .element_of method. Note that these methods only apply to classifiers and not factors (ie those that return strings and not real numbers). See the docs for more info https://www.quantopian.com/help#quantopian_pipeline_classifiers_Classifier . Something like this should work.

country_id = Fundamentals.country_id.latest  
usa = country_id.eq('USA')

See attached notebook.

Loading notebook preview...