You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[pandas] update pandas to use yfinance and minor edits (#133)
* update pandas to use yfinance and minor edits
* fix read function for yahoo finance
* remove margin as not supported in quantecon-book-theme
* add a space for title
Copy file name to clipboardExpand all lines: lectures/pandas.md
+16-4Lines changed: 16 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -34,6 +34,7 @@ In addition to what’s in Anaconda, this lecture will need the following librar
34
34
tags: [hide-output]
35
35
---
36
36
!pip install --upgrade pandas-datareader
37
+
!pip install --upgrade yfinance
37
38
```
38
39
39
40
## Overview
@@ -385,18 +386,28 @@ Note that pandas offers many other file type alternatives.
385
386
386
387
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.
387
388
388
-
### Using {index}`pandas_datareader <single: pandas_datareader>` to Access Data
389
+
### Using {index}`pandas_datareader <single: pandas_datareader>`and {index}`yfinance <single: yfinance>`to Access Data
389
390
390
391
```{index} single: Python; pandas-datareader
391
392
```
392
393
393
-
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.
394
+
The maker of pandas has also authored a library called
395
+
[pandas_datareader](https://pandas-datareader.readthedocs.io/en/latest/) that
396
+
gives programmatic access to many data sources straight from the Jupyter notebook.
394
397
395
398
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.
396
399
400
+
We will also use [yfinance](https://pypi.org/project/yfinance/) to fetch data from Yahoo finance
401
+
in the exercises.
402
+
397
403
For now let's work through one example of downloading and plotting data --- this
398
404
time from the World Bank.
399
405
406
+
```{note}
407
+
There are also other [python libraries](https://data.worldbank.org/products/third-party-apps)
408
+
available for working with world bank data such as [wbgapi](https://pypi.org/project/wbgapi/)
409
+
```
410
+
400
411
The World Bank [collects and organizes data](http://data.worldbank.org/indicator) on a huge range of indicators.
401
412
402
413
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.
@@ -426,7 +437,7 @@ With these imports:
426
437
427
438
```{code-cell} python3
428
439
import datetime as dt
429
-
from pandas_datareader import data
440
+
import yfinance as yf
430
441
```
431
442
432
443
Write a program to calculate the percentage price change over 2019 for the following shares:
0 commit comments