Created
February 11, 2020 12:21
-
-
Save e96031413/bbe345d7ab720be19c6592218283958d to your computer and use it in GitHub Desktop.
將Google Trends的資料輸出成CSV檔案,並進行時間序列繪圖
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
import pandas as pd | |
from pytrends.request import TrendReq | |
pytrend = TrendReq(hl='en-US', tz=360) | |
keywords = ['Python', 'R'] | |
pytrend.build_payload( | |
kw_list=keywords, | |
cat=0, | |
timeframe='today 3-m', | |
geo='TW', | |
gprop='') | |
data = pytrend.interest_over_time() | |
data= data.drop(labels=['isPartial'],axis='columns') | |
image = data.plot(title = 'Python V.S. R in last 3 months on Google Trends ') | |
fig = image.get_figure() | |
fig.savefig('figure.png') | |
data.to_csv('Py_VS_R.csv', encoding='utf_8_sig') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment