# This code is as according to the jupyter python console.
# importing pandas library
import pandas as pd
# loading data set
# "data" is the name of the csv file
df = pd.read_csv('data.csv')
# find total of the values of the row and assigning it to new column
df["total_marks"] = df.sum(axis=1)
# Finding average of the values
# devide by the number of the columns to get average
# I am using 5 according to my data set.
df["average_value"] = df["total_marks"]/ 5
# to show the dataset
df
Comments
Dear visitor, please use panel for submitting new questions
Write a program that reeds from a CSV file(marks.CSV stored in desired location)in a dataframe then add a column total storing total marks in there subjects and another column for storing average marks.Print the dataframe after adding these columns.
Leave a comment