You are on page 1of 8

Pract1

Pract2
Pract3
Pract4
4a
import pandas as pd
df=pd.read_csv('/content/HORUS-Audio-2ch.csv')
df1=pd.read_csv('/content/HORUS-Audio-2ch (1).txt')
print(df)
print(df1)

4b
import pandas as pd
a=[['Java',20000,'40 days'],['Python',20000,'30 days'],['R',20000,'20
days']]
column_names=['Courses','Fees','Duration']
row_label=['a','b','c']
df=pd.DataFrame(a,columns=column_names,index=row_label)
print(df)
print(df.shape)
print(df.size)
print(df.empty)
print(df.columns.values)
print(df.index.values)
print(df['Fees'])
print(df[['Fees','Duration']])
df2=df[df['Fees']==20000]
print(df2)

4c
n=1
while n<=5:
print(n)
n=n+1
4d
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
points=np.arange(-6,6,0.01)
xs,ys=np.meshgrid(points,points)
print(ys)
print(xs)
z=np.sqrt(xs**3+ys**3)
plt.imshow(z,cmap=plt.cm.gray)
plt.show()
4e
import pandas as pd
df1=pd.DataFrame(index=['a','c','e','f','h'],columns=['one','two','three']
)
df1=df1.reindex(['a','b','c','d','e','f','g','h'])
print(df1['one'])
print(df1['one'].isnull())
print(df1['one'].fillna(0))
Pract5
Pract6
6a
import pandas as pd
import numpy as np
import networkx as nx
graph = nx.DiGraph()
graph.add_edges_from([("root","a"),("a","b"),("a","e"),("b","c"),
("b","d"),("d","e")])
print(graph)
graph.nodes()
print(graph.nodes)
6b
from turtle import*
color("red")
fillcolor("yellow")
begin_fill()
while True:
forward(200)
left(170)
if abs(pos())<1:
break
end_fill()
done()

6c
import networkx as nx
import matplotlib.pyplot as plt

G = nx.Graph()
edges = [(1, 2), (1, 6), (2, 3), (2, 4), (2, 6),
(3, 4), (3, 5), (4, 8), (4, 9), (6, 7)]
G.add_edges_from(edges)

nx.draw_networkx(G, with_labels=True)
plt.show()

print("Total number of nodes: ", G.number_of_nodes())


print("Total number of edges: ", G.number_of_edges())
print("List of all nodes: ", list(G.nodes()))
print("List of all edges: ", list(G.edges(data=True)))
print("Degree for all nodes: ", dict(G.degree()))

print("Total number of self-loops: ", nx.number_of_selfloops(G))

print("List of all nodes we can go to in a single step from node 2: ",


list(G.neighbors(2)))

Pract7
import pandas as pd
import numpy as np
d = pd.read_csv('/content/Iris (1).csv')
print(d)
a=np.array(d) [:,:-1]
print("the attributes are",a)
t=np.array(d)[:,-1]
print("the target is:",t)

You might also like