Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

random sample with weights python

import random

random.choices(
  population=[a, b, c, d],  # list to pick from
  weights=[0.2, 0.2, 0.2, 0.4],  # weights of the population, in order
  k=5  # amount of samples to draw
)
Comment

PREVIOUS NEXT
Code Example
Python :: how to download nltk in python 
Python :: pandas not in list 
Python :: python datetime strftime 
Python :: pandas slicing from one column to another 
Python :: plotly hide color bar 
Python :: python sentence splitter 
Python :: how to find outliers in python 
Python :: Python Tkinter TopLevel Widget Syntax 
Python :: loop through 2 items python 
Python :: python convert dict to xml 
Python :: pandas row from dict 
Python :: radix sort python 
Python :: named tuple python iterate 
Python :: godot setget 
Python :: python binary tree 
Python :: install python in centos7 
Python :: python create list of specific length 
Python :: python logger get level 
Python :: django media root 
Python :: hello world in python 
Python :: try open file 
Python :: python count characters 
Python :: seaborn countplot 
Python :: python file count 
Python :: loop through python object 
Python :: list tuples and dictionary in python 
Python :: how to close opencv window in python 
Python :: how to create string in python 
Python :: tkinter prevent window resize 
Python :: pandas delete column by name 
ADD CONTENT
Topic
Content
Source link
Name
6+7 =