Introducing Pandas Objects

Installing and using pandas

To use pandas you require NumPy on your system. If you are using Anaconda, then you already have Numpy and Pandas installed on it.

Import pandas library

To import pandas library you use ‘import pandas’

We can check version of it you have ‘pandas.__version__’ under the ‘print’ statement. Then it prints the version you have installed on your system that you are going to use.

Instead of always using pandas keyword we can create object of it or we can say it as a alias, to make alias or object of pandas is- ‘import pandas as pd’. Here ‘pd’ becomes the object. As we know for NumPy — ‘import numpy as np’. Similary ‘np’ becomes the object of NumPy.

Alias of Pandas and NumPy

Series object in pandas

A series object in pandas is one dimensional array of data indexed. It can be created from list or arrays.

Series created from list

Here ‘s1’ is a series object, and output shows the sequence of values and its indices. Values are simply like a NumPy array.

Values can be accessed with its ‘values’ attribute.

‘values’ attribute of series

We can access index of particular series with its ‘index’ attribute

‘index’ attribute of series

Here figure shows accessing the index of particular series and shows he start index, stop index, and step of increasing position.

Series values can be accessed by associated index like python notations as shown following figure. Python series is more flexible than NumPy array

Access values by its index position