Create A Pandas Series From A Dictionary Of Values And An Ndarray - CBSE Project

 In this post, we are going to make a project of CBSE Class 12 IP. In this project, we need the help of Pandas and the NumPy library. If you don't know how to install these libraries don't worry about that I will help you how to install these libraries for Pandas type "pip install pandas" and for NumPy type "pip install numpy" in your terminal or command prompt. 

Now we will create a pandas series from a dictionary of values and a Ndarray.

Here is the code. In this code, we use the colors like Python so if you like the colors please comment.

#Create a pandas series from a dictionary of values and an ndarray
import pandas as pd
import numpy as np
items = {
    "Pen": 10,
    "Pencil": 12,
    "Notebook": 15
    }
ser1 = pd.Series(items)
print("Series object is :")
print(ser1)
#Using Numpy arry
arr = np.array([2,4,6,8])
ser2 = pd.Series(arr, index=['A','B','C','D'])
print("Series object 2 is :")
print(ser2)

Post a Comment

Previous Post Next Post