Skip to content

Commit a665da4

Browse files
authored
🔁 Update README
1 parent 221aeb4 commit a665da4

File tree

1 file changed

+37
-1
lines changed

1 file changed

+37
-1
lines changed

README.md

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ Print the first 10 Rows from a Dateframe. (Method .head(amount))
2929
print(df.head(10))
3030
```
3131

32-
3332
## Print Rows from a Dateframe and sort them with an attribute 🗃
3433
Print 10 Rows from a Dateframe using an Integer Index from 0-10 and sort them with an attribute. (Method .sort_values(["Start Time"]))
3534
```
@@ -54,3 +53,40 @@ data = {'state': ['Ohio', 'Ohio', 'Ohio', 'Nevada', 'Nevada', 'Nevada'],
5453
# Create Data Frame
5554
df = pd.DataFrame(data)
5655
```
56+
57+
## Draw financial Chart 🗂
58+
```
59+
import pandas as pd
60+
import matplotlib.pyplot as plt
61+
import matplotlib
62+
from datetime import datetime
63+
64+
fig = plt.figure()
65+
ax = fig.add_subplot(1, 1, 1)
66+
67+
data = pd.read_csv('spx.csv', index_col=0, parse_dates=True)
68+
spx = data['SPX']
69+
70+
spx.plot(ax=ax, style='k-')
71+
72+
crisis_data = [
73+
(datetime(2007, 10, 11), 'Peak of bull market'),
74+
(datetime(2008, 3, 12), 'Bear Stearns Fails'),
75+
(datetime(2008, 9, 15), 'Lehman Bankruptcy')
76+
]
77+
78+
for date, label in crisis_data:
79+
ax.annotate(label, xy=(date, spx.asof(date) + 75),
80+
xytext=(date, spx.asof(date) + 225),
81+
arrowprops=dict(facecolor='black', headwidth=4, width=2,
82+
headlength=4),
83+
horizontalalignment='left', verticalalignment='top')
84+
85+
# Zoom in on 2007-2010
86+
ax.set_xlim(['1/1/2007', '1/1/2011'])
87+
ax.set_ylim([600, 1800])
88+
89+
ax.set_title('Important dates in the 2008-2009 financial crisis')
90+
91+
fig.show()
92+
```

0 commit comments

Comments
 (0)