Pandas apply method „pd.Series.max“

Viewed 54

Please update the title accordingly as I don’t know a good title for that question. I even couldn’t find a good formulation for my question to search with.

If I call the „apply“ method on a DataFrame, my understanding is that by default, I traverse through every column. If I want to find the max value, without using the lambda function, I can go like this:

df.apply(pd.Series.max)

But I haven’t fully grasped how this method call works under the hood. Is the „pd.Series“ a wildcard for each column that gets passed in or how do I have to understand that?

1 Answers

df.apply calls the specified function for each column of the dataframe (or row, if you pass axis=1). pd.Series.max is just a function in the pd.Series object. You could use any function, e.g. the built-in max function, like df.apply(max).

Related