Home > Mobile >  How do I differentiate pandas methods and functions?
How do I differentiate pandas methods and functions?

Time:10-01

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.

CodePudding user response:

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.

  • Related