In This Article, You Will Learn About Python Pandas Series
Python Pandas Series – Before moving ahead, let’s know about Python Pandas Introduction
Table of Contents
Pandas Series
Pandas series is a one dimensional column of a table containing any data type such as int and string.
Example – Creating a simple Pandas Series from a list.
import pandas as pd
number = [1, 2, 3]
data = pd.Series(number)
print(data)
As show above, it returned one dimensional array.
Labels
Data will be automatically arranged by their index number, if label is not defined. Label is used to access particular value.
Note: Index number in Python starts from 0.
Example – Returning the second value from list.
import pandas as pd
number = [1, 2, 3]
data = pd.Series(number)
print(data[1])
As show above, it returned specified value at given index number.
Create Labels
By using index argument, we can create our own label name.
Example – Creating label names.
import pandas as pd
number = [1, 2, 3]
data = pd.Series(number, index = ["a", "b", "c"])
print(data)
As a result, it returned a Series in column-table form.
Now as label is defined, therefore you can access data from label name.
Example – Returning the second value from list.
import pandas as pd
number = [1, 2, 3]
data = pd.Series(number)
print(data["b"])
As show above, it returned specified value at given index number.
Key/Value Objects as Series
It is also possible to use the key/value object, similar to the dictionary, to create series.
Example – Creating a simple Pandas Series from a dictionary.
import pandas as pd
info = {"name": "Alex", "Roll No.": 101, "Class": X}
data = pd.Series(info)
print(data)
As a result, it returned a Series in column-table form.
Note: Now keys of dictionary will be treated as label.
To select data from dictionary, now you key as index argument.
Example – Returning the second value from list.
import pandas as pd
info = {"name": "Alex", "Roll No.": 101, "Class": X}
data = pd.Series(info, index = "name", "Class")
print(data)
As a result, it returned a specified value at given index (keys).
Data Frames
Data Frames in Pandas is usually defined as multi-dimensional column table.
import pandas as pd
info =
{
"Name": ["A", "B", "C"],
"Score": [90, 89, 98]
}
data = pd.DataFrame(info)
print(data)

As a result, it returned a Series in column-table form.
If you find anything incorrect in the above-discussed topic and have any further questions, please comment below.