import pandas as pd
import numpy as np
df = pd.DataFrame(np.random.randn(100, 4), columns=['test1_score', 'test2_score' ,'test3_score' ,'test4_score'])
df.head()
test1_score | test2_score | test3_score | test4_score | |
---|---|---|---|---|
0 | -0.562832 | 0.285719 | 0.937775 | -1.638723 |
1 | 0.298900 | -1.215272 | 1.461132 | 0.866500 |
2 | -1.049831 | 1.767881 | 0.221468 | -1.165039 |
3 | 1.360927 | 0.846616 | -1.559061 | -1.340281 |
4 | -0.022707 | 0.946102 | 0.232905 | 0.615826 |
5 rows × 4 columns
print(len(df))
100
rows = np.random.choice(df.index.values, 10)
sampled_df = df.ix[rows]
sampled_df
test1_score | test2_score | test3_score | test4_score | |
---|---|---|---|---|
61 | 0.350195 | -1.199999 | -0.277451 | -1.286770 |
46 | -0.310364 | 1.086771 | -0.521381 | 0.607132 |
78 | -0.215014 | 0.464960 | -0.369023 | -2.332646 |
9 | -1.281638 | -0.268482 | -0.103900 | 1.559594 |
78 | -0.215014 | 0.464960 | -0.369023 | -2.332646 |
48 | 0.239393 | -0.090481 | 2.453789 | -0.126449 |
68 | -1.078161 | -0.712167 | 0.303397 | 0.444029 |
68 | -1.078161 | -0.712167 | 0.303397 | 0.444029 |
51 | 0.087971 | 0.397842 | -0.086190 | -0.903375 |
80 | -0.875859 | -0.873104 | 2.316806 | 0.518988 |
10 rows × 4 columns