Compare monthly average stock prices for Facebook and Google
Now, you'll apply your new resampling skills to daily stock price series for Facebook and Google for the 2015-2016 period to compare the trend of the monthly averages.
Questo esercizio fa parte del corso
Manipulating Time Series Data in Python
Istruzioni dell'esercizio
We have again imported pandas as pd and matplotlib.pyplot as plt for you.
- Use
pd.read_csv()to import'stocks.csv'and set aDateTimeIndexbased on the'date'column usingparse_datesandindex_col, assign the result tostocksand inspect using.info(). - Create
monthly_averageby applying.resample()with monthly frequency todata, using.mean()to aggregate. Plot the result usingsubplots.
Esercizio pratico interattivo
Prova a risolvere questo esercizio completando il codice di esempio.
# Import and inspect data here
stocks = ____
print(___)
# Calculate and plot the monthly averages
monthly_average = ____