Commit 955baddc3e
Unsigned
Layout: unified · split
sampling/sample.py +7 −3
| @@ -1,8 +1,12 @@ | ||
| 1 | """ | |
| 2 | Creates a sample from a CSV or Excel file based on user-defined SAMPLE_SIZE. | |
| 3 | """ | |
| 4 | ||
| 1 | 5 | # Import packages |
| 2 | 6 | import pandas as pd |
| 3 | 7 | |
| 4 | 8 | # Define the sample size |
| 5 | sample_size = 25 | |
| 9 | SAMPLE_SIZE = 25 | |
| 6 | 10 | |
| 7 | 11 | # Import the data to a pandas DataFrame |
| 8 | 12 | df = pd.read_csv("FILENAME_GOES_HERE.csv") |
| @@ -15,8 +19,8 @@ df = pd.read_csv("FILENAME_GOES_HERE.csv") | ||
| 15 | 19 | print("Dataframe size (rows, columns): ", df.shape) |
| 16 | 20 | |
| 17 | 21 | # Sample |
| 18 | sample = df.sample(sample_size) | |
| 19 | print("Sample size: ", sample_size) | |
| 22 | sample = df.sample(SAMPLE_SIZE) | |
| 23 | print("Sample size: ", SAMPLE_SIZE) | |
| 20 | 24 | print("Sample:\n", sample) |
| 21 | 25 | |
| 22 | 26 | # ALTERNATIVE: Replacement Samples |