Created
April 29, 2021 05:45
-
-
Save therealnaveenkamal/bc46d23f3629759484b6150d90832608 to your computer and use it in GitHub Desktop.
Exploratory Data Analysis of Time Series Stock Data
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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