{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Stock Price Data" ] }, { "cell_type": "code", "execution_count": 34, "metadata": {}, "outputs": [], "source": [ "import os\n", "import pandas as pd\n", "\n", "stock_prices = {}\n", "\n", "for fn in os.listdir(\"prices\"):\n", " # Get the name of the file without extension \"aapl.csv\" -> \"aapl\"\n", " name = fn.split(\".\")[0]\n", " stock_prices[name] = pd.read_csv(os.path.join(\"prices\", fn))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We chose a dictionary where the keys are the stock symbols and the values are DataFrames from the corresponding CSV file.\n", "\n", "Let's display the data stored for the `aapl` stock symbol:" ] }, { "cell_type": "code", "execution_count": 35, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " | date | \n", "close | \n", "open | \n", "high | \n", "low | \n", "volume | \n", "
---|---|---|---|---|---|---|
0 | \n", "2007-01-03 | \n", "83.800002 | \n", "86.289999 | \n", "86.579999 | \n", "81.899999 | \n", "309579900 | \n", "
1 | \n", "2007-01-04 | \n", "85.659998 | \n", "84.050001 | \n", "85.949998 | \n", "83.820003 | \n", "211815100 | \n", "
2 | \n", "2007-01-05 | \n", "85.049997 | \n", "85.770000 | \n", "86.199997 | \n", "84.400002 | \n", "208685400 | \n", "
3 | \n", "2007-01-08 | \n", "85.470000 | \n", "85.959998 | \n", "86.529998 | \n", "85.280003 | \n", "199276700 | \n", "
4 | \n", "2007-01-09 | \n", "92.570003 | \n", "86.450003 | \n", "92.979999 | \n", "85.150000 | \n", "837324600 | \n", "