From the course: Python Data Science Mistakes to Avoid

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Not importing relevant libraries and modules

Not importing relevant libraries and modules - Python Tutorial

From the course: Python Data Science Mistakes to Avoid

Start my 1-month free trial

Not importing relevant libraries and modules

- [Instructor] A common mistake that can come up when using modules in libraries in your code is not importing them first. For example, let's say that I want to take the square root of a number. So I call the SQRT function from Python's math library like this. As you can see, when I ran the cell, I got a name error that says name math is not defined. This is because I did not import the math library before referring to its SQRT function. To fix this, I can add a cell above in which I import math. As you can see, when I rerun the cells everything worked and there were no errors. So make sure you remember to import all relevant libraries and modules first before you try to access specific functions from them.

Contents