Triple fraction of stars following given query

def triple_fraction(self,query='mass_A > 0', unc=False):
        """
        Triple fraction of stars following given query
        """
        subdf = self.stars.query(query)
        ntriples = ((subdf['mass_B'] > 0) & (subdf['mass_C'] > 0)).sum()
        frac = ntriples/len(subdf)
        if unc:
            return frac, frac/np.sqrt(ntriples)
        else:
            return frac