Categories: Pandas

How to Install & Import Pandas in Python

Pandas is one of the most powerful libraries for data analysis and is the most popular Python library, with growing usage. Before we get into the details of how to actually import Pandas, you need to remember that you will need Python successfully installed on your laptop or server. There are many ways of achieving this, but for the purposes of this post, we’re going to assume that you’ve followed through with this. For those of you who are Mac OSx users, this shouldn’t be a problem at all as Python is already pre-installed and is accessible via the command line prompt.

Installing Pandas for Python

By far the fastest path to installing pandas is by using the Anaconda distribution. Anaconda is an open-source data analysis, science, and machine learning grouping of libraries that enables quick installation and integration.

Once you have Anaconda installed, available through a UI download online, you can apply a simple prompt into the command line to install pandas.

conda install pandas

From here, you’ll need to open your python editor (Spyder, PyCharm, etc.) or utilize a Jupyter Notebook to actually be able to enter the commands found below.

import pandas as pd

So, what’s the magic command we’re looking to ensure works?

import pandas as pd

In this statement, we’re importing the Pandas library with an alias, or variable name of pd. We could just as simply right import pandas, however, each time we’d write pandas.function() to access some part of the Pandas library, which contains many functions. We in this case simply use pd as a shorthand to access pandas when necessary.

Importing Pandas Functions

In the last section we covered importing the entire Python library, however, sometimes we only want to import very specific functions to perform our data analysis.

The below two examples shows how this can be done for individual or multiple functions. The first of these shows that when we declare from pandas we can import the two basic functions of DataFrame and Series used for populating data into Pandas.

from pandas import DataFrame, Series

The second function shows how we can access nested functions which are within the sub-library of Pandas. Here we import the json_normalize function from the class. We can think of this as our directory within the python library.

from import json_normalize
Andrew W. Owens

Analytics and sciences contributor and professional. Specializing in Python and GCP.

Recent Posts

Adding rows to a Pandas Dataframe

While studying Data Science, we often come across DataFrames ready to be used. Normally, those…

6 days ago

Decision Trees in Scikit-Learn

Introduction The decision tree is a machine learning algorithm which perform both classification and regression.…

3 weeks ago

A Holistic Guide to Groupby Statements in Pandas

The Importance of Groupby Functions In Data Analysis Whether working in SQL, R, Python, or…

4 weeks ago

Logistic Regression in Sci-Kit Learn

Introduction Logistic regression is an important model used in supervised learning. You can use logistic…

1 month ago

Pandas-Profiling, explore your data faster in Python

All datasets have one obvious thing in common, information, but this information is easy and…

1 month ago

Create a DataFrame or Series from a List or Dictionary

Use Pandas Series or DataFrames to make your data life easier In this article, we…

2 months ago