Skip to content

Instantly share code, notes, and snippets.

@therealnaveenkamal
Created April 29, 2021 05:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save therealnaveenkamal/bc46d23f3629759484b6150d90832608 to your computer and use it in GitHub Desktop.
Save therealnaveenkamal/bc46d23f3629759484b6150d90832608 to your computer and use it in GitHub Desktop.
Exploratory Data Analysis of Time Series Stock Data
from pandas_datareader import data
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
df = data.DataReader("RELIANCE.NS",
data_source = "yahoo",
start = "2010-01-28",
end = "2020-12-28")
df['Date'] = pd.to_datetime(df.index)
df['Year'] = df['Date'].dt.year
df['Month'] = df['Date'].dt.month
plt.style.use("fivethirtyeight")
variable = 'Close'
fig, ax = plt.subplots(figsize=(15, 6))
sns.lineplot(df['Month'], df[variable], hue = df['Year'])
ax.set_title('Seasonal plot of Price', loc='center')
ax.set_xlabel('Month')
ax.set_ylabel('Price')
ax.legend(labels = [str(2010+i) for i in range(11)], bbox_to_anchor=(1.1, 1.05))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment