proportions

Filling null values based on the proportion of the categories in that column

Filling null values based on the proportion of the categories in that column Question: I have the following data col=[‘black’,’black’,’black’,’grey’,’white’,’grey’,’grey’,’nan’,’grey’,’black’,’black’,’red’,’nan’,’nan’,’nan’,’nan’,’black’,’black’,’white’] dd=pd.DataFrame({‘color’:col}) dd.replace(‘nan’,np.NaN,inplace=True) dd.sample(5) Out[1]: color 8 grey 14 NaN 7 NaN 2 black 9 black The following is the proportion of each color in the column dd.color.value_counts(normalize=True) Out[2]: black 0.500000 grey 0.285714 white 0.142857 red …

Total answers: 2

Pandas group-by proportion of cumulative sum start from 0

Pandas group-by proportion of cumulative sum start from 0 Question: I have the following pandas Data Frame (without 2 the last columns): name day show-in-appointment previous-missed-appointments proportion-previous-missed 0 Jack 2020/01/01 show 0 0 1 Jack 2020/01/02 no-show 0 0 2 Jill 2020/01/02 no-show 0 0 3 Jack 2020/01/03 show 1 0.5 4 Jill 2020/01/03 show …

Total answers: 1