I need to select some % of records from my dataframe for my analysis, lets say 33% of record I need to select from my dataframe, which has 100 records(as an example). I need to select randomly 33 records from my dataframe. I tried "random.randint", but this is not giving exactly 33% of records, it gives approximately 33% of records only.Below is my code:
DF_1['ran'] = [random.randint(0,99) for k in DF_1.index]
DF_2=DF_1[DF_1['ran']<33]
Do we have any other functions to get exact % of records from dataframe?. Thank you in advance. Alex