How to Master Python for Data Science
By: Chanin Nantasenamat
Tags: Editors Pick, Getting Started, Programming, Data Science, Python

3. Mindsets for Learning Python

3.1. Why are you Learning Python?

Figuring out why you’re learning Python may help you stay motivated when life’s getting in the way. Sure, having consistency and good habits may only get you so far. Having a clear reason for learning may help to boost your motivation and steer you back on track.

3.2. Don’t be Afraid to Fail or Make Mistakes

A part of learning any new technical skills is to take a dive in approach to learning. Don’t be afraid of failing or getting stuck as these are inevitable. Remember that if you’re not stuck, you’re not learning! I have always liked to approach learning new things by making as much mistakes as possible and the plus side is the valuable lessons learned that can be used for tackling it the second time around.

In fact, I have learned about the OODA loop from one of Daniel Bourke’s blog that the faster we can iterate through this loop, the better we will be in attaining intended goals.

Schematic diagram of the OODA Loop. Drawn by the Author.

The OODA loops stands for Observe, Orient, Decide and Act, which was originally a military strategy designed by US Air Force Colonel John Boyd for use in combat. The key is speed and to achieve that speed, the iteration through the loop must proceed faster. Thus, when applied in implementing coding projects, the faster we can iterate through the OODA loop the more we will learn.

3.3. Learning How to Learn

There are ample learning resources available for learning Python. Depending on the approach that resonates with you, select those that maximizes your learning potential.

3.3.1. Reading

If reading is your thing, there are several great books and written tutorials that you can learn Python from.

→ Python Basics: A Practical Introduction to Python 3

→ Automate the Boring Stuff with Python: Practical Programming for Total Beginners

→ Python Crash Course: A Hands-On, Project-Based Introduction to Programming

Some good books using Python in the context of data science and machine learning are as follows:

→ Python Data Science Handbook: Essential Tools for Working with Data

→ Python for Data Analysis: Data Wrangling with Pandas, NumPy, and IPython

→ Hands-On Machine Learning with Scikit-Learn, Keras, and TensorFlow: Concepts, Tools, and Techniques to Build Intelligent Systems

3.3.2. Visual

Perhaps you are more of a visual person then there’s a lot of great YouTube channels out there that teaches the concepts as well as practical tutorials. These includes: freeCodeCamp, Data Professor, Coding Professor, CD Dojo, Corey Schafer, Tech with Tim, Python Programmer, Data School, Keith Galli, Kylie Ying and Programming with Mosh.

3.3.3. Projects

Nothing beats learning by doing. It is also the greatest way to push your learning to the limits. The large collection of datasets available on Kaggle is a great starting point to get inspiration for starting your own projects. Guided Projects by Coursera is also another way to implement projects under the guidance of a course mentor. If you’re into live training, Data Science Dojo has an introductory Python for Data Science program that can be completed in a week’s time.

3.4. Shift from Following Coding Tutorials to Implementing your own Projects

Being able to successfully follow tutorials and being able to implement your own projects from scratch are two different things. Sure, for the former you can successfully follow each steps of the tutorial but when it comes the time that you have to figure out for your own which approach to use or which libraries/functions to use, you may succumb to the challenge and get stuck.

So how exactly can you make the transition from being a follower of coding tutorials to actually being able to implement your own projects? Find out in the next section.

3.5. Learning to Solve Problems

The answer is quite simple. You have to start doing projects. The more, the merrier. As you accumulate experience from many projects, you’re going to acquire skills pertaining to problem solving and problem framing.

To get started, follow these process:

Select an interesting problem to work on. Understand the problem. Break down the problem to the smallest parts. Implement the small parts. Next, piece together the results of these parts and holistically see if they addressed the problem. Rinse and repeat.

You may also find the project to be more engaging if you’re passionate about the topic or if it piques your interest. Look around you, what topics are you interested in and think about what you would like to know more about. For example, if you are a YouTube content creator, you may find it interesting to analyze your content in relation to its performance (e.g. views, hours watched, watch time, video clickthrough rate, etc.).

3.6. Don’t Reinvent the Wheel

You should become familiar with using Python functions to perform various tasks. In a nutshell, the thousands of Python libraries that are available on PyPI, conda or GitHub comes pre-equipped with a wide-range of functions that you can use right out of the box.

The essence of these functions is that it normally takes in input arguments for which it uses to perform a pre-defined task or sets of tasks before returning the output. Input arguments can be explicitly specified when running the function but if none are specified then Python assumes that you’re using a set of default parameters.

Before embarking on writing your own custom function, do some Googling to see if there are already some existing functions from libraries that performs similar functionalities as to what you plan on implementing. Chances are there may already be an existing function for which you just need to simply import and use.

3.7. Learning New Libraries

It should be noted that if you’re familiar with one library you’re also likely to be able to pick up other related libraries. For example, if you’re already familiar with using matplotlib , using seaborn or plotly should be fairly easy to learn and implement because the foundations are already in place. Similar with the deep learning libraries (e.g. tensorflow , torch , fastai and mxnet ).

3.8. Debugging and Asking for Help

As you code your projects and you’re code throws out errors, it is therefore essential that you learn how to debug the code and problem solve. However, if the error goes beyond your comprehension, it is very important that you know how to ask for help.

The first person that you should ask is yourself. Yes, I know you may be wondering how would that work since you’re clueless right now. By asking yourself, I mean that you first try to solve the problem yourself before you ask others for help. This is important because it goes to show your character and your persistence.

So how exactly can you debug the code and problem solve.

Read the output carefully as the reason for the error is explicitly written in the output. Sometimes even the simplest error may have slipped our mind such as forgetting to install some libraries or forgetting to first defining the variables before using it. If you are still clueless, now it’s time to start Googling. Thus, you will now have to learn how to master the Art of Asking the Right Questions. If you’re asking Google using irrelevant keywords, you may not find any useful answers in the search results. The easiest way is to include keywords related to the problem.

In the search query, I would use the following as keywords

<name of Python or R library> <copy and paste the error message>

Yes, that’s basically it. But let’s say I would like to limit my search from only Stack Overflow I would add site:stackoverflow.com as an additional statement in the search query. Or alternatively, you can head over to Stack Overflow and perform the search there.

3.9 Consistency and Accountability

A recurring theme in any learning journey is to develop a habit of learning, which will help you to become consistent in your learning journey. Coding consistently will put your momentum in action and the more you use it the more skillful you’ll become. As the saying goes:

Use it or lose it.

The 66 Days of Data initiative started by Ken Jee is a great way to build good habits of learning, maintain consistency and gain accountability for your learning. Taking part in this initiative is quite easy: