0% found this document useful (0 votes)
9 views17 pages

Practical File

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views17 pages

Practical File

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

Q1 Create a Pandas Series from a numpy array .

import pandas as pd
import numpy as np

#making 1D array

array1=np.array([100,200,300,400,500,600])
s1=pd.Series(array1)
print(s1)

OUTPUT:
Q2 Given a Series print all the elements that are
above the 75th percentile.
import pandas as pd

# Sample series
data = pd.Series([10, 20, 30, 40, 50, 60, 70, 80, 90, 100])

# Calculate the 75th percentile value


percentile_75 = data.quantile(0.75)

# Filter the series to get values above the 75th percentile


above_75th_percentile = data[data > percentile_75]

print("75th Percentile Value:", percentile_75)


print("Elements above the 75th Percentile:")
print(above_75th_percentile)

output:
Q3 Write a program to generate a Series of 10
numbers with a scalar value of 777.

import pandas as pd
def Scalar_Series():
S1=pd.Series(777,index=range(0,11))
print(S1)
Scalar_Series()

output:

Q4 Create a pandas Series from dictionary of


value.

import pandas as p
data={'year1':100,'year2':200,'year3':300}
S1=p.Series(data)
print(S1)

Output:
Q5 Creating a Line Graph using matplotlib.

import matplotlib.pyplot as plt


Year [2020,2021,2022, 2023,2024]
Sales=[1000,600,800,1600,2000]
plt.plot(Year, Sales)
plt.xlabel('Year')
plt.ylabel('Sales')
plt.title('Line-Graph')
plt.show()

Ouput:
Q6 creating a bar graph using matplotlib.

import matplotlib.pyplot as plt


Brands=['FORD', 'LAMBORGHINI', 'FERRARI', 'BMW', 'AMG']
fales=[70000, 46000, 10000,160000,42000]
plt.bar(Brands, Sales)
plt.xlabel('Year')
plt.ylabel('Sales')
plt.title('bar-Graph')
plt.show()

Output:
Q7 Creating a histogram Graph using matplotlib.

import matplotlib.pyplot as plt


import numpy as np

colors = ['Red', 'Blue', 'Green', 'Yellow']


block_counts = [15, 5, 20, 10]

plt.bar(colors, block_counts, color=colors)

plt.xlabel('Colors')
plt.ylabel('Number of Blocks')
plt.title('Number of Blocks by Color')

plt.show()

Output:
Q8 Create the following DataFrame Sales containg year
wise sales figures for five salespersons in INR. Use the
years as column labels and salesperson names as row
labels.

1. Create the DataFrame.


2. Display the row labels of Sales.
3. Display the column labels of Sales.
4. Display the data types of each column of Sales.
5. Display the dimensions ,shape, size and values of Sales.
Ans.
import pandas as pd
➢ Data={2020:[187,201,213,178,187],
➢ 2021:[359,280,254,199,321],
➢ 2022:[247,214,177,203,176],
➢ 2023:[289,381,279,169,196],
➢ 2024:[306,295,266,400,388]}
➢ Sales=pd.DataFrame(Data,index=['Josh','Andrew','Jason','Enzo','Braga'
])
➢ print(Sales)
➢ #Display row labels
➢ print('Row Labels:\n',Sales.index)
➢ print('Column Lables:\n',Sales.columns)
➢ print('Data type:\n',Sales.dtypes)
➢ print('Display the Dimensions,Shape,size and values of Sales')
➢ print('Dimensions:',Sales.ndim)
➢ print('Shape:',Sales.shape)
➢ print('Size:',Sales.size)
➢ print('Values:',Sales.values)
Q9 create a table named students having columns student
id, name ,class ,marks, tuition fee.
Q10 Insert 10 values in the table named students.
Q11 Use various types of multi row functions in table
named students.
Q12 Add a new column(Grade) into existing table name
students.
Q13 Add values in new column(Grade) into existing table
named students.
Q14 Apply the function ORDER BY on the table named
students.
Q15 Apply the function GROUP BY on the table named
students.

Q16 Apply the function UPPER and LOWER on the table


named students.
Q17 Apply date functions on the table named students.
INDEX
S.NO CONTENT SIGN
1 Create a Pandas Series from a numpy array .
2 Given a Series print all the elements that are
above the 75th percentile.
3 Write a program to generate a Series of 10
numbers with a scalar value of 777.
4 Create a pandas Series from dictionary of value.
5 Creating a Line Graph using matplotlib.
6 Creating a Bar Graph using matplotlib.
7 Creating Histogram Graph using matplotlib.
8 Create the following DataFrame Sales containg
year wise sales figures for five salespersons in
INR. Use the years as column labels and
salesperson names as row labels.
9 create a table named students having columns
student id, name ,class ,marks, tuition fee.
10 Insert 10 values in the table named students.
11 Use various types of multi row functions in table
named students.
12 Add a new column(Grade) into existing table
name students.
13 Add values in new column(Grade) into existing
table named students.
14 Apply the function ORDER BY on the table
named students.
15 Apply the function GROUP BY on the table
named students.
16 Apply the function UPPER and LOWER on the
table named students.
17 Apply date functions on the table students.

You might also like