Last active
November 11, 2024 19:39
-
-
Save brianckeegan/8872048 to your computer and use it in GitHub Desktop.
Generates a random pandas DataFrame containing categories, timestamps, integers, and random floats. Useful for debugging or answering StackOverflow questions.
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 as pd | |
import numpy as np | |
import datetime | |
dft = pd.DataFrame({'A' : ['spam', 'eggs', 'spam', 'eggs'] * 6, | |
'B' : ['alpha', 'beta', 'gamma'] * 8, | |
'C' : [np.random.choice(pd.date_range(datetime.datetime(2013,1,1),datetime.datetime(2013,1,3))) for i in range(24)], | |
'D' : np.random.randn(24), | |
'E' : np.random.random_integers(0,4,24)}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment