Pandas Introduction
Pandas is a Python library for working with tables of data. A table holds rows and columns, like a spreadsheet.
Import pandas
This line brings pandas into Python. It prints nothing on its own.
import pandas as pdCheck the version
The first part of the version number is 3. Print it to check the import worked.
import pandas as pd
print(pd.__version__.split(".")[0])Example
import pandas as pd
print(pd.__version__.split(".")[0])
print(pd.__name__)Key points
- A DataFrame is a table with rows and columns.
- Use pandas to read a file into a table and look at the table.
- Import pandas with the line import pandas as pd.
- The short name pd stands for pandas in code.
- Tables hold numbers and words in rows and columns.
In this example, pandas is imported with its short name pd. The first print shows the first part of the version number, 3. The second print shows the library name.
Note
Pandas is an add-on library, so plain Python does not include it.
Try it Yourself
Edit the code, then press Run.
Running is simulated Β· Python Playground
Exercise
What is pandas?