← Back to Pandas Course | Chapter 1: Getting Started | Lesson 3 of 7

Importing Pandas

Everyone imports Pandas as pd so code looks the same across the whole community.

In this page:

  1. Importing Pandas
Syntax
python
import pandas as pd
import numpy as np

Importing Pandas

The standard import is import pandas as pd, usually alongside import numpy as np. After that, all functions are reached as pd.something. The pd alias is used in almost every tutorial, book and Stack Overflow answer.

Note: Printing pd.__version__ is the fastest way to confirm what you are running.

Example: Importing Pandas

python
import pandas as pd
import numpy as np

print(type(pd.__version__))
s = pd.Series([1, 2, np.nan])
print(s)

# Output:
# <class 'str'>
# 0    1.0
# 1    2.0
# 2    NaN
# dtype: float64
Related Topics
Common Mistakes
  1. Using a different alias
  2. Using from pandas import *
  3. Forgetting to import numpy when needed
Chapter Summary
  • import pandas as pd
  • Often paired with import numpy as np
  • pd.__version__ shows the version
  • Avoid star imports
🔒

Chapter Quiz — Complete all 7 topics to unlock

0/7 topics done

Complete these topics first:

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.