Created
August 28, 2021 17:35
-
-
Save marcosan93/e35f2755fdd0ea3bc85744f4c08d7280 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| def random_dob(start, end, n): | |
| """ | |
| Generating a list of a set number of timestamps | |
| """ | |
| # The timestamp format | |
| frmt = "%Y-%m-%d" | |
| # Formatting the two time periods | |
| stime = datetime.datetime.strptime(start, frmt) | |
| etime = datetime.datetime.strptime(end, frmt) | |
| # Creating the pool for random times | |
| td = etime - stime | |
| # Generating a list with the random times | |
| times = [(random.random() * td + stime).strftime(frmt) for _ in range(n)] | |
| return times | |
| df['dob'] = random_dob("1980-01-01", "2006-01-01", num_users) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment