0% found this document useful (0 votes)
24 views2 pages

NumPy and Pandas Array Creation Guide

The document provides practical examples of using NumPy and Pandas in Python for creating arrays and series. It includes code snippets for creating a NumPy array, a Pandas Series from a dictionary, and accessing elements from a Series. Additionally, it demonstrates how to create a DataFrame using a dictionary.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views2 pages

NumPy and Pandas Array Creation Guide

The document provides practical examples of using NumPy and Pandas in Python for creating arrays and series. It includes code snippets for creating a NumPy array, a Pandas Series from a dictionary, and accessing elements from a Series. Additionally, it demonstrates how to create a DataFrame using a dictionary.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

PRACTICAL NO.

25

#numpy array creation


import numpy as np
arr=np.array([10,20,30,40,50,60])
print(arr)
Output:

Q.2 Write a Python program to create series from array using Panda.
import pandas as pd
import numpy as np
d={"Name":["Siddhi","Shreya","Samrudhi"],"age":[23,18,19],"Roll no":[21,22,23]}
a=np.array([1,2,3,4,7,8,9])
s=pd.Series(d)
print(s)
Output:

Q.3 Write a Python program to create and accessing series from list using Panda.
#create a series from list
d=[10,30,40,50,60,70,80]
s=pd.Series(d)
print(s)
#accessing members of Series
print(s[2])
print(s[5])
Output:
Q.5 Write a Python program to create DataFrame using list or dictionary
using Panda.

import pandas as pd
d={"Name":["Siddhi","Shreya","Samrudhi"],"age":[23,18,19],"Roll no":
[21,22,23]}
df=pd.DataFrame(d)
print(df)
Output:
OUTPUT:

You might also like