Installation Of Pandas
Pandas is a powerful Python library used for data manipulation and analysis. If you have Python and PIP already installed on your system, then the installation of Pandas is very easy.
pip install pandas
If this command fails, try using a Python distribution that already includes Pandas such as Anaconda, Spyder, or Jupyter Notebook.
Importing Pandas
Program:
import pandas
mydataset = {
'cars': ["BMW", "Volvo", "Ford"],
'passings': [3, 7, 2]
}
myvar = pandas.DataFrame(mydataset)
print(myvar)
Output:
cars passings
0 BMW 3
1 Volvo 7
2 Ford 2
Importing Pandas As 'pd'
What is an alias?
Alias: In Python, an alias is an alternate name for referring to the same module or object.
You can create an alias using the as keyword.
How to import NumPy with an alias?
import pandas as pd
Now the Pandas package can be referred to as pd instead of pandas.
Program:
Output:
cars passings
0 BMW 3
1 Volvo 7
2 Ford 2
Checking Pandas Version
The version string of Pandas is stored under the __version__ attribute.
import pandas as pd
print(pd.__version__)