PW Akshay


generate functionFri, 02 Dec 2022

Create a binary file with roll number, name and marks. Input a roll number and update the marks

#importing pandas library import pandas as pd #creating a dataframe df = pd.DataFrame({"Roll No.": [1,2,3,4,5,6,7,8,9,10], "Name": ["A","B","C","D","E","F","G","H","I","J"],"Marks":[65,75,85,84,93,95,80,88,78,86]}) #saving dataframe to csv file df.to_csv("data.csv") #opening dataframe from csv file df2 = pd.read_csv("data.csv") #updating dataframe df2 = df2.append({'Roll No.':4, 'Name':'D', 'Marks':85}, ignore_index=True) #saving dataframe to csv file df2.to_csv("data.csv")

Questions about programming?Chat with your personal AI assistant