'Select a random values from a list and fill the column of df - pandas [duplicate]
I have a data frame with the customers as shown below.
df:
id name
1 john
2 dan
3 sam
also, I have a list as
['www.costco.com', 'www.walmart.com']
I would like to add a column named domain to df by randomly selecting the elements from the list.
Expected output:
id name domain
1 john www.walmart.com
2 dan www.costco.com
3 sam www.costco.com
Note: since it is a random selection output may not be the same as always.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
