Skip to main content

Collect and visualize twitter poll data.

Project description

tweepypoll

Overview

tweepypoll is a Python package that allows users to extract and visualize poll data (poll questions, poll options, poll responses, etc.) from Twitter. Our goal is to make tweepypoll helpful and user-friendly; any Python beginner can effectively gain access to the data and make their own data-driven decisions. In particular, it could be a useful package for people doing social media journalism, or those studying social media interactions.

NOTE: This package assumes that the user has signed up for Twitter API Developer account, acquired the bearer token and set the environmental variable "BEARER_TOKEN". To acquire the bearer token, please follow the instructions here.

Functions

  • get_polls_from_user:

    • This function retrieves a list of tweet IDs (where the tweet contains a poll) from a Twitter user. These ids can be fed into the get_poll_by_id function.
    • The function will only search through the most 100 recent tweets per requested user.
  • get_poll_by_id:

    • This function extracts poll information from Twitter given the tweet ID returned from the get_polls_from_user function.
  • visualize_poll:

    • This function takes in the output of get_poll_by_id function and visualizes the poll information.

Related Packages

There are a few existing Python packages that have similar functionality for tweets from Twitter. For example, pytweet is a package that helps extract tweets, visualize user habit on tweet posting, and apply sentiment analysis to the data. However, there are no available packages that work specifically on polls from Twitter.

Installation

$ pip install tweepypoll

Dependencies

  • python = "^3.9"
  • altair = "^4.2.0"
  • pandas = "^1.3.5"
  • tweepy = "^4.4.0"
  • python-dotenv = "^0.19.2"

Usage

from tweepypoll.tweepypoll import get_polls_from_user
get_polls_from_user('username')

where username is a string username, such as 'ElonMusk'

from tweepypoll.tweepypoll import get_poll_by_id
get_poll_by_id(tweet_id)

tweet_id is numeric, such as 1481040318325739523

from tweepypoll.tweepypoll import visualize_poll
visualize_poll(poll_obj, show_user=False, show_duration=False, show_date=False)

poll_obj is a dict outputted by get_poll_by_id(), show_user, show_duration, show_date are optional booleans to display username, poll duration and poll end date, respectively

Contributors

  • Wenxin Xiang
  • Rada Rudyak
  • Linh Giang Nguyen

Contributing

Interested in contributing? Check out the contributing guidelines. Please note that this project is released with a Code of Conduct. By contributing to this project, you agree to abide by its terms.

License

tweepypoll was created by Wenxin Xiang, Rada Rudyak, Linh Giang Nguyen. It is licensed under the terms of the MIT license.

Credits

tweepypoll was created with cookiecutter and the py-pkgs-cookiecutter template.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tweepypoll-0.2.1.tar.gz (6.0 kB view details)

Uploaded Source

Built Distribution

tweepypoll-0.2.1-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

Details for the file tweepypoll-0.2.1.tar.gz.

File metadata

  • Download URL: tweepypoll-0.2.1.tar.gz
  • Upload date:
  • Size: 6.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.10

File hashes

Hashes for tweepypoll-0.2.1.tar.gz
Algorithm Hash digest
SHA256 2e50d96549634ec6a8e1f1b5debbbeb8972ba9564ff937608741b00578d84f24
MD5 5226e74f1ccb78fcf81983f72bac4d94
BLAKE2b-256 0aed06e51be7992308fdce247151e7a282f6764a4f94ae76651f67fc8f7e6ddc

See more details on using hashes here.

File details

Details for the file tweepypoll-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: tweepypoll-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 5.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.10

File hashes

Hashes for tweepypoll-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 771ed900b57f664056d12624a8536eff1b76aed2988aca62c6ced0654ea9be72
MD5 0e599341d036288101f34c5542d984df
BLAKE2b-256 e8dd0a57dc196e1a2b19cc57ce5bb8e918618ab19b231b0f5f5c14ac9cdc863e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page