I have a DataFrame made of boolean values. What I want is to check whether all entries are True
by applying some function that simply outputs True
or False
after looking at each individual entry. Is there an easy or elegant way to do this?
And more generally speaking, say I have some DataFrame and I want to apply a function to the entries and output a single value (e.g. sum all the elements up, or take the product of all the elements). Is there some native way to create a function of the form
def f(df):
return single_value(df)
I have seen plenty of methods that subject DataFrame entries to functions, but they all return a DataFrame (most of the time changing it in place). A mathematical example of what I want would be a vector norm since it maps vectors (series in pds) to positive real values.
question from:https://stackoverflow.com/questions/66061797/function-of-pandas-dataframe-that-creates-single-value-output