Last active
December 13, 2019 02:23
-
-
Save GeorgeSeif/c9587178bb71475d45dbe9106f3623c5 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
import random | |
import pandas as pd | |
NUM_ROWS = 1000000 | |
symbols = ["AAPL", "GOOG", "AMZN", "NFLX", "MSFT"] | |
prices = [random.randint(1, 500) for _ in range(50)] | |
def generate_random_stock_data(symbols, prices): | |
return {"symbol": random.sample(symbols, 1)[0], | |
"price" : random.sample(prices, 1)[0]} | |
stock_data = [generate_random_stock_data(symbols, prices) for _ in range(NUM_ROWS)] | |
stock_df = pd.DataFrame(stock_data, | |
columns=["symbol","price"]) | |
stock_df.to_csv("stock_data.csv") | |
print(stock_df) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment