What Is “import pandas as pd”?

Pandas is an open-source Python library that consists of multiple modules for high-performance, easy-to-use data structures, and data analysis tools. The pandas module is named as pandas and can be imported into the Python script, applications, or interactive terminal with “import pandas“. But what is “import pandas as pd” which is very popular amongst Python developers, examples even the official pandas documentation use.

Install pandas Library

In order to import and use the pandas library first it should be installed by using different methods in different operating systems.

Install pandas For Ubuntu, Mint, Debian:

sudo apt install python3-pandas

Install pandas For Fedora, CentOS, RHEL:

sudo yum install python3-pandas

Install pandas with pip Command:

pip3 install pandas

import pandas as pd

The pandas module can be imported by using the import pandas. But when we try to use the pandas module functions we should use the pandas term in every time. This can be trivial task to use pandas in every call. So alias cna be specified for the imported module and in this case the pd term can be specified as alias to the pandas.

import pandas as pd

Use pandas with pd Alias

The pd alias is used to access pandas module functions. In the following example we will read the csv file with the pandas module read_csv() method. The pd can be used as shortcut for the pandas module.

import pandas as pd

data = pd.read_csv("users.csv")

Set Different Alias Then pd

Even the alias pd is very popular and referred as the pandas module alias we can use another alias whatever we want. In the following exampl we will set the p as the pandas module alias instead of pd.

import pandas as p

data = p.read_csv("users.csv")

Leave a Comment