Class03 Answer:

Use Pandas to plot prices of GSPC for 2016.

One way to learn Pandas is to study examples.

Another way is by asking good questions of Google:


This script should use Pandas to plot prices of GSPC for 2016.


import pandas as pd
import matplotlib.pyplot as plt

csvfile_s = ''
# Goog: In pandas how to sort a dataframe?
cp_df = pd.read_csv(csvfile_s).sort_values(['cdate'])
# Goog: In pandas how to filter?
cp2016_sr = (cp_df.cdate > '2016') & (cp_df.cdate < '2017')
cp2016_df = cp_df[['cdate','cp']][cp2016_sr]

# I should plot
cpdate2016_df = cp2016_df.set_index(['cdate'])
# Goog: In Pandas what is an index?
# Goog: In Pandas what does set_index do?
cpdate2016_df.plot.line(title="GSPC 2016") # This line might be slow


Class03 Lab About Blog Contact Class01 Class02 Class03 Class04 Class05 Class06 Class07 Class08 Class09 Class10 dan101 Forum Google Hangout Vboxen