Hi,
I have below data in txt file, and I want to calculate same rows column sum and percentage of passed. I use below code, but I can not get my desired output. Each name has different categories. I want to calculate passing rate of names (which comprise different categories)
P has 1 pass and 1 fail, so its passing rate is 50%.
I have below data in txt file, and I want to calculate same rows column sum and percentage of passed. I use below code, but I can not get my desired output. Each name has different categories. I want to calculate passing rate of names (which comprise different categories)
import pandas as pd df = pd.read_csv(r'D:\Mekala_Backupdata\PythonCodes\tmpdata.txt', delimiter= '\s+', index_col=False) df['category'].value_counts()
name category score A s 1 P g 0 U L 1 A tr 1 A re 1 U re 1 P p 1desired output:
A 100% P 50% U 100%
1 represents -->pass 0 represents --> failA have 3 category and all pass so, passing rate is 100%.
P has 1 pass and 1 fail, so its passing rate is 50%.