difference between "function()" and "function"
In 1, the function len is being passed to a method called apply. That method presumably will apply the function len along the first axis (probably returning something like a list of lengths). In 2, the function len is being called directly, with an argument df["col2"], presumably to get the length of the data frame.
The use in 1 is sometimes called a "higher order function", but in principle it's just passing a function to another function for it to use.
I see

df["col2"] = df["col1"].apply(len)
len(df["col1"])

My question is,

Why use "len" function without parenthesis in 1, but use it with parenthesis in 2?

What is the difference between the two?


I see this kind of occasion a lot, where using a function with and without parenthesis.
Can someone explain to me what exactly is going on?
Thanks.