desert_ranger
desert_ranger

Reputation: 1737

How do I differentiate pandas methods and functions?

While going over various blog posts, I see conflicting terms regarding some of pandas operations. For instance, this website refers to read_csv() as a function. Whereas this website refers to groupby() as a method.

My intuition is that since data frame and series are pandas objects, whenever we operate with them, it's a method and function otherwise. For instance, groupby() in df.groupby() is a method since df is a data frame which is an object.

Upvotes: 0

Views: 189

Answers (1)

Riley
Riley

Reputation: 2261

Your strict definition is probably technically correct but in the python space you will find these words used interchangeably.

A lot of the pandas "methods" actually start out as "functions", and get stitched on to the class as methods using setattr.

Upvotes: 1

Related Questions