6. Read the ‘Student_result.csv’ to create a data frame and do the following operation:

To display Student_result file with new column names.

To modify the Percentage of student below 40 with NaN value in
dataframe.

Solution :- 

import pandas as pd
import numpy as np
#import csv
df=pd.read_csv(“Student.csv”)
print(df)

#To display Student_result file with new column names.
df1 = pd.read_csv(“Student.csv”,skiprows=1,
names=[‘Adm_No’,’Roll no’ ,’Name’ ,’Gender’ ‘S1′,’S2′,’S3′,’S4′,’S5′,’S6′,’total’,’Perc’])
print(“To display Student_result file with new column names”)
print(df1)

#To modify the Percentage of student below 40 with NaN value.
df2 = pd.read_csv(“Student.csv”)
print(df2)
print(“To modify the percentage od Student below 40 with NaN value.”)
df2.loc[(df2[‘Perc’]<40,’Perc’)]=np.nan
print(df2)