Pandas Getting Started

Dhanapriya D

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

Once Pandas is installed, import it in your application by using the import keyword:

import pandas

Now Pandas is imported and ready to use.

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'

Pandas is usually imported under the pd alias.

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: 

import pandas as pd
mydataset = {
 'cars': ["BMW", "Volvo", "Ford"],
 'passings': [3, 7, 2]
}
myvar = pd.DataFrame(mydataset)
print(myvar)

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__)



Our website uses cookies to enhance your experience. Learn More
Accept !

GocourseAI

close
send