Object Oriented Programming Python

MIKE ARMISTEAD
2 min readSep 24, 2020

--

When I first learned python we were taught quickly about objects and how to create them but never when to use them and why they are important. Then I started to look at Github pages and noticed that everyone starts by creating classes and I wasn’t sure why. For that reason I dove deeper into object oriented programming and figured out how to use it when creating data science projects. One of the first things that I found interesting is that a lot of libraries that I use all the time are heavily based on OOP. For example Pandas has certain functions in it that no other library has and that is because Pandas has its own built in functions through objects.

Objects in programming can bundle properties and functions to themselves. The analogy I see a lot that makes the most sense to me is a person may have properties of a first name, last name, age, height and weight. Then they have functions such as eating, walking, sleeping and working. The reason to bundle properties and functions is because you may need a function to only happen to a certain type of data so you can have the function be in the same object as that data.

For the purpose of a data science project we need to think about things that we do to our data. When ever we use data there is some sort of cleaning and formatting that needs to be done so the data will work in our model. This can now become a function to our class of data. I use to make a function that would clean my data but with objects it can miss some properties and still work properly. If you did that with a function it would crash.

--

--

MIKE ARMISTEAD
MIKE ARMISTEAD

Written by MIKE ARMISTEAD

Tech recruiter turned Data Scientist

No responses yet