Inspecting the regression data
The next dataset contains information about company market value over several years of time. This is one of the most popular kind of time series data used for regression. If you can model the value of a company as it changes over time, you can make predictions about where that company will be in the future. This dataset was also originally provided as part of a public Kaggle competition.
In this exercise, you'll plot the time series for a number of companies to get an understanding of how they are (or aren't) related to one another.
This exercise is part of the course
Machine Learning for Time Series Data in Python
Exercise instructions
- Import the data with Pandas (stored in the file
'prices.csv'
). - Convert the index of
data
todatetime
. - Loop through each column of
data
and plot the the column's values over time.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Read in the data
data = pd.____('prices.csv', index_col=0)
# Convert the index of the DataFrame to datetime
data.index = ____(data.index)
print(data.head())
# Loop through each column, plot its values over time
fig, ax = plt.subplots()
for column in ____:
data[column].plot(ax=ax, label=column)
ax.legend()
plt.show()