It is pandas/Dataframe, it contains all scores for everyone everyday, I want to add one extra column to collect how many time it has the highest score (could be more than one people and some data are nan)
import pandas as pd
import numpy as np
data = np.array([['','day1','day2','day3','day4','day5'],
['larry',1,4,7,3,5],
['niko',2,-1,3,6,4],
['tin',np.nan,5,5, 6,7]])
df = pd.DataFrame(data=data[1:,1:],
index=data[1:,0],
columns=data[0,1:])
print(df)
output
day1 day2 day3 day4 day5
larry 1 4 7 3 5
niko 2 -1 3 6 4
tin nan 5 5 6 7
expected result is (larry: 1 time, niko: 2 times, tin: 3 times)
times_of_top day1 day2 day3 day4 day5
larry 1 1 4 7 3 5
niko 2 2 -1 3 6 4
tin 3 nan 5 5 6 7
niko has the highest score on day1 and day4 so his times_of_top is 2.
tin has the highest score on day2, day4 and day5 so his times_of_top is 3.