Random distribution of generated values in different columns

Viewed 25

I randomly generated numbers and below you can see a small example of my data.

import pandas as pd
import numpy as np
data = {
         'total_sales':[0,120,180,90,30,90],
        }
df1 = pd.DataFrame(data, columns = [
                                      'total_sales',])

enter image description here

Now I want to divide this amount into three other columns. So actually total_sales now represents the sum of three columns (group_1,group_2, and group_3).

enter image description here

So far so good. But now I want to divide total_sales into these three groups on the bases of probability let's say each third element will be randomly distributed between those groups (group_1, group_2, and group_3 ). Examples are shown in a row that started with the value of 180 and the last row from the table which started with 90.

So can anybody help me with how to solve this problem?

enter image description here

0 Answers
Related