HW1 Problem 1¶
Part A¶
In [1]:
import os
os.getcwd()
Out[1]:
'C:\\Users\\YKN\\Documents\\CompFin\\hw1'
os.getcwd() is a method in Python's os module that retrieves the current working directory. It returns a string representing the path of the folder where the Python script or code is currently being executed.
Part B¶
In [7]:
import pandas as pd
inflation = pd.read_csv('CPIAUCSL.csv')
print(inflation.head())
DATE CPIAUCSL_PC1 0 1948-01-01 10.24209 1 1948-02-01 9.48196 2 1948-03-01 6.81818 3 1948-04-01 8.27273 4 1948-05-01 9.38497
| DATE | CPIAUCSL_PC1 | |
|---|---|---|
| 0 | 1948-01-01 | 10.24209 |
| 1 | 1948-02-01 | 9.48196 |
| 2 | 1948-03-01 | 6.81818 |
| 3 | 1948-04-01 | 8.27273 |
| 4 | 1948-05-01 | 9.38497 |
Part C¶
In [11]:
inflation.plot(x='DATE', y='CPIAUCSL_PC1')
Out[11]:
<Axes: xlabel='DATE'>
In [13]:
inflation.plot(x='DATE', y='CPIAUCSL_PC1', ylabel='Annual Percent Change', legend=True, title='US Inflation Rate (CPI)')
Out[13]:
<Axes: title={'center': 'US Inflation Rate (CPI)'}, xlabel='DATE', ylabel='Annual Percent Change'>
I prefer the graph from the FRED database maintained by the Federal Reserve Bank of St. Louis, because its graph can be scaled and selected to study in detail or over a period of time, but my graph made with Pandas is fixed and less detailed.