<jupyter_start><jupyter_text>1. Sentiment data<jupyter_code>import pandas as pd
import os
url = "https://www.frbsf.org/economic-research/indicators-data/daily-news-sentiment-index/files/news_sentiment_data.xlsx"
df = pd.read_excel(url, sheet_name=1, index_col=[0], parse_dates=[0])
df.head(3)
df.plot();
os.mkdir('Data_output')
df.to_csv('Data_output/Shaprio_2020_data.csv')<jupyter_output><empty_output><jupyter_text>2. Replication data<jupyter_code>from io import BytesIO
from zipfile import ZipFile
from urllib.request import urlopen
files = !ls
if 'news_sentiment_replication_code' in files:
    pass
else:
    url = "https://www.frbsf.org/economic-research/indicators-data/daily-news-sentiment-index/files/news_sentiment_replication_code.zip"
    resp = urlopen(url)
    zipfile = ZipFile(BytesIO(resp.read()))
    zipfile.extractall()<jupyter_output><empty_output><jupyter_text>2.1 Dictionary<jupyter_code>lm_dict = pd.read_csv('news_sentiment_replication_code/LoughranMcDonald_2016.csv')
lm_dict.head(2)<jupyter_output><empty_output><jupyter_text>2.2 Vader sentences<jupyter_code>vader = pd.read_csv('news_sentiment_replication_code/ns.vader.sentences.20k.csv')
vader.head(2)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12788778877887788, 'fraction_numerical': 0.018151815181518153, 'mean_word_length': 7.854014598540146, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '450824', 'license': 'MIT', 'n_tokens_mistral': 489, 'n_tokens_neox': 468, 'n_words': 54, 'path': 'Shapiro_2020/Data_download.ipynb', 'repo_name': 'corybaird/Macro_replication_presentations', 'size': '1212'}