Rudra Aiml 1.4
Rudra Aiml 1.4
Rudra Aiml 1.4
Experiment 1.4
Student Name:Rudra Shakti Kar UID: 21BCS7176
Branch: CSE Section/Group: IOT_633A
Semester: 5th Date of Performance: 12/09/23
Subject Name: AIML Lab Subject Code: 21CSH-316
A. Pandas
1. Algorithm:
2. Source Code:
a)
import pandas as pd
import numpy as np
info = np.array(['R’,’U’,’D’,’R’,’A’])
a = pd.Series(info)
print(a)
b)
import pandas as pd
x = ['RUDRA','21BCS7176','633 A']
df = pd.DataFrame(x)
print(df)
3. Output:
a) b)
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
B. Matplotlibs
1. Algoritm:
1. Import the matplotlib.pyplot module as plot.
2. Import the numpy module as nup.
3. Create a numpy array k using the linspace function, ranging from 1 to 3 (inclusive), with 2
evenly spaced values.
4. Create a numpy array r using the linspace function, ranging from 2 to 1 (inclusive), with 3
evenly spaced values.
5. Create a numpy array q using the linspace function, ranging from 3 to 2 (inclusive), with 1
evenly spaced value.
6. Use the plot.plot() function to plot the arrays k, r, and q. Each array is plotted against itself,
and a label is assigned for each plot: "k" for k, "r" for r, and "q" for q.
7. Add a legend to the plot using plot.legend() to display labels for each plotted line.
8. Display the plot using plot.show().
2. Source Code:
a)
import matplotlib.pyplot as plt
import numpy as np
xpoints = np.array([0, 7])
ypoints = np.array([0, 260])
plt.plot(xpoints, ypoints)
plt.show()
b)
import matplotlib.pyplot as plt
import numpy as np
ypoints = np.array([3, 8, 1, 10])
plt.title("21BCS7176")
plt.plot(ypoints, marker = 'o')
plt.show()
c)
import matplotlib.pyplot as plt
import numpy as np
ypoints = np.array([3, 8, 1, 10])
plt.plot(ypoints, linestyle = 'dotted')
plt.show()
DEPARTMENT OF
COMPUTER
d)
SCIENCE & ENGINEERING
import matplotlib.pyplot as plt
import numpy as np
y = np.array([35, 25, 25, 15])
plt.title("UID:21BCS7176")
plt.pie(y)
plt.show()
3. Output:
a) b)
c) d)
4. Learning Outcomes:
Understanding of creating and manipulating Data Frames in pandas.
Knowledge of adding columns with different data types to a Data Frame.
Proficiency in creating and customizing plots using Matplotlib.