Importing Pandas
Everyone imports Pandas as pd so code looks the same across the whole community.
In this page:
Syntax
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
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
- Using a different alias
- Using from pandas import *
- 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: