Adding random values between one to three to a column of a DataFrame conditional on some conditions
This seems like 2 separate questions
For 1, one idea is to just hash the firm name and then that will give you a deterministic way of setting which firm goes to which industry.
For 2, one idea is to use a permutation function. For example, you can use numpy.shuffle where the first 4 belong to all 3, then the next 15 belong to a random subset of 2... etc, etc.
You could then generate tables off of all this information and use joins to concatenate your final table, where you initially start off with just trade dates, firms, and deal info.
(This is just a starting idea)
I want to generate a Dataframe which involves three industries, 100 investors, and 2000 firms in 50000 different deals. So, I have 50000 rows and four columns, including deal's date.
I randomly assigned 100 investors and 2000 firm in this dataset for all deals.
My problem is that I need to determine the industry for each deal by considering a couple of conditions that should hold for this process. 1) If a firm randomly assigned to an industry, this firm should hold in the same industry in the whole dataset. 2) All investors invest at least in one industry, 15 investors invest at least in two industries, and four investors invest in all three industries. I don't know how I can do this.