[Solved] pd.DataFrame(np.random.randn(8, 4), index=dates, columns=[‘A’, ‘B’, ‘C’, ‘D’])


Basically np.random.randn returns random float values of normal distributions with mean = 0 and variance = 1. Now np.random.randn takes shape you would like to return of those distributions.

For example:

np.random.randn(1,2) returns an array of one row and two columns. Similarly, you can give np.random.randn(1,.,.,.,9) which gives you out a complicated array. Since you have mentioned np.random.randn(6, 4) it returned you 6 rows and 4 different columns.

For documentation refer: Check this

solved pd.DataFrame(np.random.randn(8, 4), index=dates, columns=[‘A’, ‘B’, ‘C’, ‘D’])