I'm trying to generate a DataFrame that has random values; something like this:
In [75]: df
Out[75]:
Name mag1 mag2 mag3 redshift
0 Galaxy 1 11.657170 12.881492 14.230583 0.1125
1 Galaxy 2 19.720113 14.297871 NaN 1.2252
2 Galaxy 3 11.026038 11.116287 17.689447 2.5548
3 Galaxy 4 NaN 16.218209 11.928297 1.8845
4 Galaxy 5 15.287412 19.199692 19.392112 4.5512
5 Galaxy 6 12.283413 12.425423 19.141460 0.9583
6 Galaxy 7 18.738156 NaN 16.179031 1.8271
7 Galaxy 8 16.277030 13.728240 11.800716 2.8819
8 Galaxy 9 16.672178 14.608468 10.145000 3.9710
9 Galaxy 10 17.836160 17.828570 13.813578 0.2790
The columns have been generated with
col0 = ['Galaxy 1','Galaxy 2','Galaxy 3','Galaxy 4','Galaxy 5','Galaxy 6','Galaxy 7','Galaxy 8','Galaxy 9','Galaxy 10']
col1 = np.array([np.random.uniform(10, 20, 10)])
col2 = np.array([np.random.uniform(10, 20, 10)])
col3 = np.array([np.random.uniform(10, 20, 10)])
col4 = np.array([np.random.uniform(0.01, 5, 10)])
and stitched together with
df = pd.DataFrame(list(zip(col0, col1, col2, col3, col4)))
The NaNs were inserted manually (no Nans in redshift).
This works fine, but how could I automate this to produce a random DataFrame with a variable number of mags but with a similar structure? Perhaps with a call like df = random_df(size = (20, 5) for 20 Galaxies and 5 mag columns?