{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "*This notebook contains material from [nbpages](https://jckantor.github.io/nbpages) by Jeffrey Kantor (jeff at nd.edu). The text is released under the\n", "[CC-BY-NC-ND-4.0 license](https://creativecommons.org/licenses/by-nc-nd/4.0/legalcode).\n", "The code is released under the [MIT license](https://opensource.org/licenses/MIT).*" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "< [2.3 Heirarchical Tagging](https://jckantor.github.io/nbpages/02.03-Heirarchical-Tagging.html) | [Contents](toc.html) | [Tag Index](tag_index.html) | [2.5 Lint](https://jckantor.github.io/nbpages/02.05-Lint.html) >
"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# IMPORT DATA FILES USED BY THIS NOTEBOOK\n",
"import os, requests\n",
"\n",
"file_links = [(\"data/Stock_Data.csv\", \"https://jckantor.github.io/nbpages/data/Stock_Data.csv\")]\n",
"\n",
"# This cell has been added by nbpages. Run this cell to download data files required for this notebook.\n",
"\n",
"for filepath, fileurl in file_links:\n",
" stem, filename = os.path.split(filepath)\n",
" if stem:\n",
" if not os.path.exists(stem):\n",
" os.mkdir(stem)\n",
" if not os.path.isfile(filepath):\n",
" with open(filepath, 'wb') as f:\n",
" response = requests.get(fileurl)\n",
" f.write(response.content)\n"
]
},
{
"cell_type": "markdown",
"metadata": {
"nbpages": {
"level": 1,
"link": "[2.4 Working with Data and Figures](https://jckantor.github.io/nbpages/02.04-Working-with-Data-and-Figures.html#2.4-Working-with-Data-and-Figures)",
"section": "2.4 Working with Data and Figures"
}
},
"source": [
"# 2.4 Working with Data and Figures"
]
},
{
"cell_type": "markdown",
"metadata": {
"nbpages": {
"level": 2,
"link": "[2.4.1 Importing data](https://jckantor.github.io/nbpages/02.04-Working-with-Data-and-Figures.html#2.4.1-Importing-data)",
"section": "2.4.1 Importing data"
}
},
"source": [
"## 2.4.1 Importing data\n",
"\n",
"The following cell reads the data file `Stock_Data.csv` from the `data` subdirectory. The name of this file will appear in the data index."
]
},
{
"cell_type": "code",
"execution_count": 62,
"metadata": {
"nbpages": {
"level": 2,
"link": "[2.4.1 Importing data](https://jckantor.github.io/nbpages/02.04-Working-with-Data-and-Figures.html#2.4.1-Importing-data)",
"section": "2.4.1 Importing data"
}
},
"outputs": [
{
"data": {
"text/html": [
"
\n", " | DJI | \n", "GSPC | \n", "IXIC | \n", "RUT | \n", "VIX | \n", "
---|---|---|---|---|---|
0 | \n", "14447.75000 | \n", "1551.689941 | \n", "3235.300049 | \n", "945.849976 | \n", "13.74 | \n", "
1 | \n", "14559.65039 | \n", "1563.770020 | \n", "3252.479980 | \n", "949.820007 | \n", "12.77 | \n", "
2 | \n", "14526.16016 | \n", "1562.849976 | \n", "3256.520020 | \n", "950.239990 | \n", "13.15 | \n", "
3 | \n", "14578.54004 | \n", "1569.189941 | \n", "3267.520020 | \n", "951.539978 | \n", "12.70 | \n", "
4 | \n", "14572.84961 | \n", "1562.170044 | \n", "3239.169922 | \n", "938.789978 | \n", "13.58 | \n", "
"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"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.7.4"
}
},
"nbformat": 4,
"nbformat_minor": 4
}