<s> from operator import itemgetter <EOL> import re <EOL> import numpy as np <EOL> import pandas as pd <EOL> get_unit_and_periods = itemgetter ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> def parse_treasury_csv_column ( column ) : <EOL> """<STR_LIT>""" <EOL> column_re = re . compile ( <EOL> r"<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> ) <EOL> match = column_re . match ( column ) <EOL> if match is None : <EOL> raise ValueError ( "<STR_LIT>" % column ) <EOL> unit , periods = get_unit_and_periods ( match . groupdict ( ) ) <EOL> return str ( int ( periods ) ) + ( '<STR_LIT>' if unit == '<STR_LIT:Y>' else '<STR_LIT>' ) <EOL> def earliest_possible_date ( ) : <EOL> """<STR_LIT>""" <EOL> return pd . Timestamp ( '<STR_LIT>' , tz = '<STR_LIT>' ) <EOL> def get_treasury_data ( start_date , end_date ) : <EOL> return pd . read_csv ( <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" , <EOL> skiprows = <NUM_LIT:1> , <EOL> parse_dates = [ '<STR_LIT>' ] , <EOL> na_values = [ '<STR_LIT>' ] , <EOL> index_col = <NUM_LIT:0> , <EOL> ) . loc [ <EOL> start_date : end_date <EOL> ] . dropna ( <EOL> how = '<STR_LIT:all>' <EOL> ) . rename ( <EOL> columns = parse_treasury_csv_column <EOL> ) . tz_localize ( '<STR_LIT>' ) * <NUM_LIT> <EOL> def dataconverter ( s ) : <EOL> try : <EOL> return float ( s ) / <NUM_LIT:100> <EOL> except : <EOL> return np . nan <EOL> def get_daily_10yr_treasury_data ( ) : <EOL> """<STR_LIT>""" <EOL> url = "<STR_LIT>" "<STR_LIT>" "<STR_LIT>" <EOL> return pd . read_csv ( url , header = <NUM_LIT:5> , index_col = <NUM_LIT:0> , names = [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> parse_dates = True , converters = { <NUM_LIT:1> : dataconverter } , <EOL> squeeze = True ) </s>
