I have a pandas.core.series.Series
object that looks like this:
6 7
8 9
18 19
35 36
42 43
I want to get a list of 3 randomly chosen numbers from this list. I tried following the advice here and tried
sampled_list = random.sample(df['ID'], 3)
with no luck. Any suggestions?
CodePudding user response:
I think you're looking for:
df['ID'].sample(3).tolist()
CodePudding user response:
sampled_list = random.sample(list(df['ID']), 3)