Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add feature: get monthly interest over specified regions #430

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dongskyler
Copy link

@dongskyler dongskyler commented Aug 21, 2020

Fix #429

Motivations:

Get interests over specified regions by the month.

When we look at long-term multi-year trends, interests by the hour is too fine, but interests by the year may not yield enough resolution. Hence, interest by the month is here to fulfill the need.

What this pull request does:

Add a method under Class TrendReq to get interests over selected geopolitical regions by the month.

The code takes care of the 29-day Februaries in leap years.

Sample response and screenshots:

Let's generate a sample response from the newly added code on the interests of 'coca cola' vs 'pepsi' by the month globally (by each country), generated by a sample driver code:

pytrend = TrendReq()
response = pytrend.get_monthly_interest(['coca cola', 'pepsi'], year_start=2019, month_start=1, year_end=2020, month_end=1, cat=0, geo='', gprop='', sleep=0)
response.to_csv('temp.csv')

Below are 2 screenshots of the saved CSV file. You can see monthly trends of each country of 'coca cola' vs 'pepsi'.

Screen Shot 2020-08-21 at 1 39 38 PM

Screen Shot 2020-08-21 at 1 40 07 PM

@arthurcst
Copy link

I think instead of concating CSVs prob would be better if you made them columns with the period as column name, would be more readable!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature request: Get interests by the month over a period and over a region
2 participants