You are on page 1of 3

CODE:06

import NumPy as np
x = np.array([[1,2],[3,4]])
print("Original array:")
print(x)
print("Sum of all elements:")
print(np.sum(x))
print("Sum of each column:")
print(np.sum(x, axis=0))
print("Sum of each row:")
print(np.sum(x, axis=1))

OUTPUT:06

Original array:
[[1 2]
[3 4]]
Sum of all elements: 10
Sum of each row: [ 3 7]
Sum of each column: [4 6]

CODE:07
import numpy as np
a=[]
b=[]
i=int(input("Enter the number of elements you want to enter forarray 1"))
for p in range(0,i):
l=int(input("Element"))
a.append(l)
i=int(input("Enter the number of elements you want to enter forarray
2"))
for p in range(0,i):
l=int(input("Element"))
b.append(l)
print(a)
print(b)
print("Union of two arrays :", np.union1d(a, b))

OUTPUT:07

Enter the number of elements you want to enter for array 11


Element3
Enter the number of elements you want to enter for array 24
Element3
Element5
Element4
Element1
[3]
[3, 5, 4, 1]
Union of two arrays : [1 3 4 5]
CODE:08

import pandas as pd
List1=[['Arpit',80],["Nilesh",90]]
print("Dataframes Are:")
d=pd.DataFrame(l,columns=['Names','Marks'])
print(d)
print("Series Are:")
e=pd.Series([2,4,1,5,6,2])
print(e)

OUTPUT:08

Dataframes Are:
Names Marks
0 Amit 80
1 Neha 90
Series Are:
02
14
21
35
46
52
dtype: int64

You might also like