GithubHelp home page GithubHelp logo

xuxiaobogit / gtrends Goto Github PK

View Code? Open in Web Editor NEW

This project forked from reagentx/gtrends

0.0 1.0 0.0 35 KB

A Google Trends Analytics Package

License: GNU General Public License v3.0

Python 100.00%

gtrends's Introduction

gtrends: A Google Trends Analytics Package

Inspired by this reddit post, I wanted to build a simple platform to pull data from Google Trends. The author made the interesting choice not to normalize the data (i.e., that the value of popularity does not represent the same amount of search volume across each category).

While this means that it does not compare the actual popularity of the social networks, it does elucidate where the networks' popularity happens to spike in the context of other networks' popularity. I built in an option that allows you to specify whether to normalize or not.

The get() function is multiprocessed, thus multiple keywords will be handled concurrently to speed up data collection routines. The number of processes depends on the number of keywords passed, however, Google may rate limit overly ambitious requests. The script checks if the requested data already exists in the output folder before making new queries.

Normalized

Normalized

Not Normalized

Not Normalized

Usage

For an example on how to use this script see run.py in the scripts folder. In short, define a list of keywords:

keywords = ['Facebook', 'Instagram', 'Twitter', 'Google Plus', 'Reddit']

Determine if you want to normalize:

normalize = False

Generate a GoogleTrendsData object:

gt = generate.GoogleTrendsData(keywords, normalize)

Run gt.get():

data = gt.get()

This will return a Pandas DataFrame. Happy analyzing!

Built-in Functions

gt.save(data)

Will export the data to a CSV file. This is useful because the script checks the output folder before making new queries, thus reducing the likelihood of hitting the rate limit.

gt.grapgh(data, file_name)

Will save an image of the line graph using pandas.plot().


Notes

  • Google only allows you to normalize up to five keywords at once. Trying to normalize more than 5 keywords will raise a ValueError.
  • Google may rate limit you if you make too many requests which can lead to TypeErrors or ResponseErrors.
  • This package is dependent on pandas and pytrends which can be installed via pip.

gtrends's People

Contributors

reagentx avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.