Last active
March 13, 2016 21:03
-
-
Save nomeyer/b50bf167de4054e6b479 to your computer and use it in GitHub Desktop.
Sample from a Pandas DataFrame (from http://stackoverflow.com/questions/15923826/random-row-selection-in-pandas-dataframe)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas | |
df = pandas.DataFrame(data) | |
# Randomly sample 70% of your dataframe | |
df_0.7 = df.sample(frac=0.7) | |
# Randomly sample 7 elements from your dataframe | |
df_7 = df.sample(n=7) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment