Home Packages in Python
Post
Cancel

Packages in Python

Since Python is so widely used, there are many people who contribute to continuously improving and developing it. Let’s imagine Python as a base version. It can do basic calculations, but it requires extra efforts to do more complicated things. People have created extras or add-ons to help create shortcuts for more complicated specific tasks or functions. These ‘add-ons’ are called modules. A module allows us to use already defined classes, functions, variables, and more. Packages are a collection of similar modules. These modules are stored together in a package to help with storage and ease of use.

Packages can be imported to use to help make things easier. For example, there is a Python package called math that helps with basic mathematical operations.

To use a package or specific module within it, we use the import command. The format of these commands is as followed:

import package.subpackage.modulename

We can also nickname the packages to make it easier when we use them. This is done using the as statement. An example of this is import pandas as pd. By doing this, whenever a function from pandas is used, instead of having to type pandas.function_name, we can type pd.function_name. This may not seem like a big difference, but when it is used repeatedly, this can save a lot of time and effort.

A few of the main packages used in python include:

Package NameUsageStandard Import Command
NumPyUsed for arrays, matricies and mathematical functionsimport numpy as np
pandasUsed with data framesimport pandas as pd
matplotlibTypically used for plotting functionsfrom matplotlib import pyplot as plt
altairMore advanced plotting optionsimport altair as alt
SciPyUsed for scientific and technical computingimport scipy

There are many other packages available, and you can even create your own as well! To see a list of the top packages available in Python, visit this link.

This post is licensed under CC BY 4.0 by the author.