Skip to content

Instantly share code, notes, and snippets.

@jcheong0428
Created November 15, 2021 03:35
Show Gist options
  • Save jcheong0428/9688dc6200537d9e8d98e808ff104f64 to your computer and use it in GitHub Desktop.
Save jcheong0428/9688dc6200537d9e8d98e808ff104f64 to your computer and use it in GitHub Desktop.
backpain_1.py
# Install pystan
!pip install -q pystan
# Install Facebook Prophet
!pip install -q fbprophet
# Download Google Trends data
!git clone https://gist.github.com/jcheong0428/838a1b1daf67473373da50627bc1bbda
!cp 838a1b1daf67473373da50627bc1bbda/*.csv .
import pandas as pd
import seaborn as sns
sns.set_context("talk")
import matplotlib.pyplot as plt
plt.rc("axes.spines", top=False, right=False)
df = pd.read_csv("/content/backpain_timeline.csv", skiprows=0)
df['date'] = pd.to_datetime(df.Month)
df.set_index('date',inplace=True)
f,ax=plt.subplots(figsize=(8,6))
df.plot(ax=ax)
ax.set(xlabel='time')
ax.set_ylabel('searches\n(relative %)', rotation=0, labelpad=60)
ax.axvline(pd.to_datetime('2020-04-01'), color='k', linestyle='--', lw=2)
plt.legend(['back pain', 'lower back pain', 'chiropractor near me', 'April 1st, 2020'], bbox_to_anchor=(1.05, .65), loc=2, borderaxespad=0.)
plt.title("Search trends for keywords", y=1.1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment