import numpy as np
import pandas as pd
from datetime import datetime
import matplotlib. pylab as plt
df= pd. read_csv( 'Quarterly.csv' )
df. head( 5 )
df. shape
import matplotlib. ticker as ticker
x= df[ 'Quarter' ]
y= df[ 'St' ]
plt. figure( figsize= ( 12 , 6 ) )
plt. plot( x, y)
plt. plot( [ x[ 0 ] , 224 ] , [ 0 , 0 ] )
plt. gca( ) . xaxis. set_major_locator( ticker. MultipleLocator( 20 ) )
plt. title( 'The interest rate spread' )
plt. show( )
diff_st= [ ]
a= [ ]
for i in range ( 0 , 222 ) :
a= y[ i+ 1 ] - y[ i]
diff_st. append( a)
plt. figure( figsize= ( 12 , 6 ) )
plt. plot( x[ 0 : 222 ] , diff_st)
plt. plot( [ x[ 0 ] , 224 ] , [ 0 , 0 ] )
plt. title( 'First-difference of the spread' )
plt. gca( ) . xaxis. set_major_locator( ticker. MultipleLocator( 20 ) )
plt. show( )
time0= np. linspace( 0 , 222 , 223 )
time1= np. linspace( 0 , 221 , 222 )
series0= df[ 'St' ]
series1= diff_st
df0= pd. DataFrame( { 'date0' : time0[ : ] , 'series0' : series0[ : ] } )
df0. to_csv( 'D://0.csv' , encoding= 'utf-8' , index= False )
df1= pd. DataFrame( { 'date1' : time1[ : ] , 'series1' : series1[ : ] } )
df1. to_csv( 'D://1.csv' , encoding= 'utf-8' , index= False )