When do I need to assign the result of a function to a variable?

I have a basic question regarding the relationship between the functions and the variables.

for some functions, we need to assign the result to a variable, such as:
class_size = class_size.groupby(‘DBN’).agg(numpy.mean) (just some code from some execrises).

some of them do not, such as:
class_size.reset_index(inplace = True)

I am so confused when do I need to assign the function result to a variable and when not. Can someone please explain it to me?

Thank you in advance.

I would recommend going through some existing answers that can help you understand this better -

The above should help you out.

Thank you, I thought it was because of the function.