CommencerCommencer gratuitement

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.

Cet exercice fait partie du cours

Manipulating Time Series Data in Python

Afficher le cours

Instructions

We have again imported pandas as pd and matplotlib.pyplot as plt for you.

  • Use pd.read_csv() to import 'stocks.csv' and set a DateTimeIndex based on the 'date' column using parse_dates and index_col, assign the result to stocks and inspect using .info().
  • Create monthly_average by applying .resample() with monthly frequency to data, using .mean() to aggregate. Plot the result using subplots.

Exercice interactif pratique

Essayez cet exercice en complétant cet exemple de code.

# Import and inspect data here
stocks = ____
print(___)

# Calculate and plot the monthly averages
monthly_average = ____


Modifier et exécuter le code