You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
``sample`` also allows users to sample columns instead of rows using the ``axis`` argument.
568
568
569
569
.. ipython :: python
570
570
571
-
df3 = DataFrame({'col1':[1,2,3], 'col2':[2,3,4]})
572
-
df3.sample(n=1, axis = 1)
571
+
df3 = DataFrame({'col1':[1,2,3], 'col2':[2,3,4]})
572
+
df3.sample(n=1, axis=1)
573
573
574
574
Finally, one can also set a seed for ``sample``'s random number generator using the ``random_state`` argument, which will accept either an integer (as a seed) or a numpy RandomState object.
575
575
576
576
.. ipython :: python
577
577
578
-
df4 = DataFrame({'col1':[1,2,3], 'col2':[2,3,4]})
578
+
df4 = DataFrame({'col1':[1,2,3], 'col2':[2,3,4]})
579
579
580
-
# With a given seed, the sample will always draw the same rows.
581
-
df4.sample(n=2, random_state = 2)
582
-
df4.sample(n=2, random_state = 2)
580
+
# With a given seed, the sample will always draw the same rows.
0 commit comments