Skip to content

Instantly share code, notes, and snippets.

@GeorgeSeif
Last active December 13, 2019 02:23
Show Gist options
  • Save GeorgeSeif/c9587178bb71475d45dbe9106f3623c5 to your computer and use it in GitHub Desktop.
Save GeorgeSeif/c9587178bb71475d45dbe9106f3623c5 to your computer and use it in GitHub Desktop.
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