Answer to Question #145397 in Python for Sriparvathy k

Question #145397
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.
1
Expert's answer
2020-11-19T08:31:16-0500
# 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

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

Assignment Expert
19.11.20, 18:48

Dear visitor, please use panel for submitting new questions

Dharmarajan
19.11.20, 16:08

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

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS