Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ jobs:
- name: Display Pip Versions
shell: bash -l {0}
run: pip list
- name: Download "build" folder (cache)
uses: dawidd6/action-download-artifact@v2
with:
workflow: publish.yml
branch: master
name: build-cache
path: _build
- name: Build HTML
shell: bash -l {0}
run: |
Expand All @@ -29,8 +36,8 @@ jobs:
shell: bash -l {0}
run: |
jb build lectures --path-output ./ --builder=custom --custom-builder=jupyter
mkdir _build/html/_notebooks
cp _build/jupyter/*.ipynb _build/html/_notebooks
mkdir -p _build/html/_notebooks
cp -u _build/jupyter/*.ipynb _build/html/_notebooks
- name: Preview Deploy to Netlify
uses: nwtgck/actions-netlify@v1.1
with:
Expand Down
17 changes: 14 additions & 3 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
name: Build & Publish to GH Pages
on:
push:
branches:
- master
tags:
- 'publish*'
jobs:
publish:
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -17,7 +18,7 @@ jobs:
miniconda-version: 'latest'
python-version: 3.8
environment-file: environment.yml
activate-environment: lecture-python-programming
activate-environment: quantecon
- name: Display Conda Environment Versions
shell: bash -l {0}
run: conda list
Expand All @@ -32,6 +33,11 @@ jobs:
shell: bash -l {0}
run: |
jb build lectures --path-output ./ --builder=custom --custom-builder=jupyter
zip -r download-notebooks.zip _build/jupyter
- uses: actions/upload-artifact@v2
with:
name: download-notebooks
path: download-notebooks.zip
- name: Copy Download Notebooks for GH-PAGES
shell: bash -l {0}
run: |
Expand All @@ -43,6 +49,11 @@ jobs:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: _build/html/
cname: python-programming.quantecon.org
- name: Upload "_build" folder (cache)
uses: actions/upload-artifact@v2
with:
name: build-cache
path: _build
- name: Prepare lecture-python-programming.notebooks sync
shell: bash -l {0}
run: |
Expand Down
10 changes: 0 additions & 10 deletions _notebook_repo/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,4 @@ channels:
dependencies:
- python=3.8
- anaconda
- pip
- pip:
- git+https://github.com/executablebooks/jupyter-book.git
- sphinxext-rediraffe
- git+https://github.com/executablebooks/sphinx-multitoc-numbering
- git+https://github.com/executablebooks/sphinx-exercise.git
- joblib
- interpolation
- git+https://github.com/QuantEcon/sphinx-tojupyter.git
- git+https://github.com/QuantEcon/quantecon-book-theme.git

16 changes: 10 additions & 6 deletions environment.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
name: lecture-python-programming
name: quantecon
channels:
- default
dependencies:
- python=3.8
- anaconda=2020.07
- anaconda=2020.11
- pip
- pip:
- jupyter-book
- sphinxext-rediraffe
- sphinx-multitoc-numbering
- joblib
- interpolation
- sphinx-tojupyter
- quantecon-book-theme
- sphinx-tojupyter
- sphinxext-rediraffe
- sphinx-exercise
- jupytext
- ghp-import
- jupinx
# Temporary Fixes
- tornado>=6.1

6 changes: 6 additions & 0 deletions lectures/_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ sphinx:
description: This website presents a set of lectures on python programming for economics, designed and written by Thomas J. Sargent and John Stachurski.
keywords: Python, QuantEcon, Quantitative Economics, Economics, Sloan, Alfred P. Sloan Foundation, Tom J. Sargent, John Stachurski
google_analytics_id: UA-54984338-9
launch_buttons:
notebook_interface : classic # The interface interactive links will activate ["classic", "jupyterlab"]
binderhub_url : https://mybinder.org # The URL of the BinderHub (e.g., https://mybinder.org)
jupyterhub_url : https://datahub.berkeley.edu # The URL of the JupyterHub (e.g., https://datahub.berkeley.edu)
thebe : false # Add a thebe button to pages (requires the repository to run on Binder)
colab_url : https://colab.research.google.com # The URL of Google Colab (https://colab.research.google.com)
rediraffe_redirects:
index_toc.md: intro.md
tojupyter_static_file_path: ["source/_static", "_static"]
Expand Down
3 changes: 2 additions & 1 deletion lectures/_toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,5 @@

- part: Other
chapters:
- file: troubleshooting
- file: troubleshooting
- file: status
17 changes: 14 additions & 3 deletions lectures/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,22 @@ kernelspec:
This website presents a set of lectures on Python programming for economics and finance, designed and written by
[Thomas J. Sargent](http://www.tomsargent.com/) and [John Stachurski](http://johnstachurski.net/). This is the first text in the series, which focuses on programming in Python.

```{admonition} News
```{admonition} New Build System
[QuantEcon](https://quantecon.org) is moving to the [Jupyter Book](https://jupyterbook.org/intro.html)
build system for all of its projects. We are a founding member of the
[Executable Books Project](https://github.com/executablebooks) and this
is the first in the QuantEcon lecture series to migrate. Please send feedback to [contact@quantecon.org](mailto:contact@quantecon.org)
[Executable Books Project](https://github.com/executablebooks), an international collaboration to
build open source tools that facilitate publishing using the Jupyter
ecosystem. Please send feedback to [contact@quantecon.org](mailto:contact@quantecon.org)
```

```{admonition} News
Tom Sargent, Chase Coleman, and Spencer Lyon have put together The [NYU Computational Social
Science: Certificate Program](http://www.tomsargent.com/nyu_css.html).
It uses many [quantecon](https://quantecon.org/lectures/index.html)
resources. The program aims to prepare students for either a graduate program in the social
sciences or for a career as a data analyst or computational social scientist.

[Applications and additional information are available here](https://as.nyu.edu/content/nyu-as/as/departments/computational-social-science.html)
```

For an overview of the series, see [this page](https://quantecon.org/python-lectures/)
Expand Down
20 changes: 16 additions & 4 deletions lectures/pandas.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ In addition to what’s in Anaconda, this lecture will need the following librar
tags: [hide-output]
---
!pip install --upgrade pandas-datareader
!pip install --upgrade yfinance
```

## Overview
Expand Down Expand Up @@ -385,18 +386,28 @@ Note that pandas offers many other file type alternatives.

Pandas has [a wide variety](https://pandas.pydata.org/pandas-docs/stable/user_guide/io.html) of top-level methods that we can use to read, excel, json, parquet or plug straight into a database server.

### Using {index}`pandas_datareader <single: pandas_datareader>` to Access Data
### Using {index}`pandas_datareader <single: pandas_datareader>` and {index}`yfinance <single: yfinance>` to Access Data

```{index} single: Python; pandas-datareader
```

The maker of pandas has also authored a library called pandas_datareader that gives programmatic access to many data sources straight from the Jupyter notebook.
The maker of pandas has also authored a library called
[pandas_datareader](https://pandas-datareader.readthedocs.io/en/latest/) that
gives programmatic access to many data sources straight from the Jupyter notebook.

While some sources require an access key, many of the most important (e.g., FRED, [OECD](https://data.oecd.org/), [EUROSTAT](https://ec.europa.eu/eurostat/data/database) and the World Bank) are free to use.

We will also use [yfinance](https://pypi.org/project/yfinance/) to fetch data from Yahoo finance
in the exercises.

For now let's work through one example of downloading and plotting data --- this
time from the World Bank.

```{note}
There are also other [python libraries](https://data.worldbank.org/products/third-party-apps)
available for working with world bank data such as [wbgapi](https://pypi.org/project/wbgapi/)
```

The World Bank [collects and organizes data](http://data.worldbank.org/indicator) on a huge range of indicators.

For example, [here's](http://data.worldbank.org/indicator/GC.DOD.TOTL.GD.ZS/countries) some data on government debt as a ratio to GDP.
Expand Down Expand Up @@ -426,7 +437,7 @@ With these imports:

```{code-cell} python3
import datetime as dt
from pandas_datareader import data
import yfinance as yf
```

Write a program to calculate the percentage price change over 2019 for the following shares:
Expand Down Expand Up @@ -460,7 +471,8 @@ def read_data(ticker_list,
ticker = pd.DataFrame()

for tick in ticker_list:
prices = data.DataReader(tick, 'yahoo', start, end)
stock = yf.Ticker(tick)
prices = stock.history(start=start, end=end)
closing_prices = prices['Close']
ticker[tick] = closing_prices

Expand Down
20 changes: 20 additions & 0 deletions lectures/status.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
jupytext:
text_representation:
extension: .md
format_name: myst
kernelspec:
display_name: Python 3
language: python
name: python3
---

# Execution Statistics

This table contains the latest execution statistics.

```{nb-exec-table}
```

These lectures are built on `linux` instances through `github actions` so are
executed using the following [hardware specifications](https://docs.github.com/en/actions/reference/specifications-for-github-hosted-runners#supported-runners-and-hardware-resources)