Create Pandas dataframe with random numbers
Pandas
import pandas as pd
import numpy as np
Create a dataframe with random integers
#using numpy's randint
df = pd.DataFrame(np.random.randint(0,100,size=(15, 4)), columns=list('ABCD'))
#preview the df
df
A | B | C | D | |
---|---|---|---|---|
0 | 91 | 96 | 36 | 89 |
1 | 17 | 18 | 40 | 97 |
2 | 38 | 12 | 22 | 63 |
3 | 38 | 13 | 17 | 96 |
4 | 48 | 68 | 65 | 59 |
5 | 45 | 28 | 65 | 79 |
6 | 49 | 73 | 36 | 20 |
7 | 0 | 69 | 11 | 87 |
8 | 90 | 19 | 49 | 7 |
9 | 93 | 35 | 97 | 55 |
10 | 28 | 80 | 27 | 40 |
11 | 74 | 42 | 1 | 26 |
12 | 81 | 12 | 28 | 53 |
13 | 63 | 63 | 60 | 61 |
14 | 10 | 54 | 39 | 0 |