Humeyra K.

asked • 03/25/21

how do I calculate average value of columns of a file in Python?

import pandas as pd


my_file = pd.read_csv("file.tsv", sep="\t")

my_file.head()

my_file['item_price'].mean()

I could easily do this by using Pandas. However how could I do it without using Pandas?

>how do I loop file's columns

>how do I add them up?


order_id quantity item_name item_price

0 1 pizza 34.2

1 1 chips 2.3

2 2 cola 2.0

3 3 burger 10.2

4 1 tart 6.43

1 Expert Answer

By:

Patrick B. answered • 03/27/21

Tutor
4.7 (31)

Math and computer tutor/teacher

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.