Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
'bool' object has no attribute 'ndim' ?

I am trying to filter stocks out that have bad "growth grades" (from fundamental data).

growthGrade = morningstar.asset_classification.growth_grade.latest  
goodGrade = growthGrade =="A"  or growthGrade =='A-' or growthGrade =='A+'

pipe = Pipeline(,  
        columns = {  
            'goodGrade' : goodGrade  
        }  
    )  

I get the following error...
AttributeError: 'bool' object has no attribute 'ndim'

If there is a better way to do this, I would love to hear it.

1 response

The 'growth_grade'is actually a classifier and not technically a factor. Classifiers have some helpful methods which factors don't. See https://www.quantopian.com/help#quantopian_pipeline_classifiers_Classifier .

The method that you may want to use is the 'element_of' method. Here's the code. I've attached a notebook where you can see it in action.

# Create your factor/classifiers. In this case  'growth_grade' is actually a classifier  
growthGrade = morningstar.asset_classification.growth_grade.latest 

# Create any filters. In this case using the '.element_of' method  
goodGrade = growthGrade.element_of(['A', 'A-', 'A+'])

# Define a 'pipeline' with our classifier and our filter  
pipe = Pipeline(  
        columns = {  
            'growthGrade' : growthGrade,  
            'goodGrade' : goodGrade,  
        }  
    )