I want to get the index and value (non-zero) which have a max total.
A = np.matrix([[0,2,1,0],
[0,0,0,0],
[1,3,0,1],])
slst = ['S1','S2','S3','S4']
namelist= ['Alice','John','Joe']
df = pd.DataFrame(A,columns = slst, index = namelist)
df.loc['total'] = df.select_dtypes(pd.np.number).sum()
print (df)
Output:
S1 S2 S3 S4
Alice 0 2 1 0
John 0 0 0 0
Joe 1 3 0 1
total 1 5 1 1
And I want to get the result from this table below. How to get it?
Output1:
Alice: 2,
Joe: 3