I have a pandas dataframe df
which appears as following:
Month Day mnthShape
1 1 1.016754224
1 1 1.099451003
1 1 0.963911929
1 2 1.016754224
1 1 1.099451003
1 2 0.963911929
1 3 1.016754224
1 3 1.099451003
1 3 1.783775568
I want to get the following from df
:
Month Day mnthShape
1 1 1.016754224
1 2 1.016754224
1 3 1.099451003
where the mnthShape
values are selected at random from the index. i.e. if the query is df.loc[(1, 1)] it should look for all values for (1, 1) and select randomly from it a value to be displayed above.