{ "cells": [ { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "import pandas as pd" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [], "source": [ "df_apple = pd.read_csv('../coal-price-data/investing/AAPL Historical Data.csv')\n", "df_walmart = pd.read_csv('../coal-price-data/investing/WMT Historical Data.csv')\n", "df_tesla = pd.read_csv('../coal-price-data/investing/TSLA Historical Data.csv')" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
DatePriceOpenHighLowVol.Change %
002/01/2024182.52183.97191.00179.2645.12M-1.02%
101/01/2024184.40187.15196.38180.171.19B-4.22%
212/01/2023192.53190.33199.62187.451.06B1.36%
311/01/2023189.95171.00192.93170.121.10B11.23%
410/01/2023170.77171.22182.34165.671.17B-0.26%
........................
51305/01/19810.150.130.150.12590.42M15.38%
51404/01/19810.130.110.130.11536.93M18.18%
51503/01/19810.110.120.120.10700.72M-8.33%
51602/01/19810.120.120.130.11321.62M-7.69%
51701/01/19810.130.150.160.13608.99M-13.33%
\n", "

518 rows × 7 columns

\n", "
" ], "text/plain": [ " Date Price Open High Low Vol. Change %\n", "0 02/01/2024 182.52 183.97 191.00 179.26 45.12M -1.02%\n", "1 01/01/2024 184.40 187.15 196.38 180.17 1.19B -4.22%\n", "2 12/01/2023 192.53 190.33 199.62 187.45 1.06B 1.36%\n", "3 11/01/2023 189.95 171.00 192.93 170.12 1.10B 11.23%\n", "4 10/01/2023 170.77 171.22 182.34 165.67 1.17B -0.26%\n", ".. ... ... ... ... ... ... ...\n", "513 05/01/1981 0.15 0.13 0.15 0.12 590.42M 15.38%\n", "514 04/01/1981 0.13 0.11 0.13 0.11 536.93M 18.18%\n", "515 03/01/1981 0.11 0.12 0.12 0.10 700.72M -8.33%\n", "516 02/01/1981 0.12 0.12 0.13 0.11 321.62M -7.69%\n", "517 01/01/1981 0.13 0.15 0.16 0.13 608.99M -13.33%\n", "\n", "[518 rows x 7 columns]" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df_apple" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "df = pd.merge(df_apple[['Date', 'Adj Close']], df_walmart[['Date', 'Adj Close']], on='Date', how='right').rename(columns = {'Adj Close_x':'apple', 'Adj Close_y':'walmart'})\n", "df = df.merge(df_tesla[['Date', 'Adj Close']], on='Date', how='right').rename(columns={'Adj Close':'tesla'})" ] } ], "metadata": { "kernelspec": { "display_name": "py311-kfp240-airflow251", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.12.1" } }, "nbformat": 4, "nbformat_minor": 2 }