I was wondering how I could calculate whether each row was above or below average, for every category via Python? I have a csv file called test.csv. For example, category 2, I have two values. First I need to calculate the mean of that category and then whether each value is above or below avg percentage. I don't know how to do the latter.
import pandas as pd
import numpy as np
#loading the data into data frame
X = pd.read_csv('test.csv')
The two columns of interest are the Category and Totals column:
Category Totals estimates
2 2777 043
4 1003 06
4 3473 065
4 2638 017
1 2855 04
0 2196 03
0 2630 91
2 2714 39
3 2472 0.51
0 1090 0.12