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 list of dicts 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.3.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

tweepypoll-0.2.3-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: tweepypoll-0.2.3.tar.gz
  • Upload date:
  • Size: 6.1 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.3.tar.gz
Algorithm Hash digest
SHA256 4976307c156c9ce9143651544f00f39c86ef71ba3610f668cb58ed643e54643f
MD5 6b7c904f41621fc931963263877fb3f1
BLAKE2b-256 c5c513c6124e45c712acc151c20c1803b84712479e1f2f400f819dab51a26ab5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tweepypoll-0.2.3-py3-none-any.whl
  • Upload date:
  • Size: 6.0 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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 e291debe2de1d4e9df7d4bc33ef642585f81628f14ff3d5a283f24c64f8e692e
MD5 d4c9cc597002621ecb0d2a25c4bc7415
BLAKE2b-256 dde99912688bc899a703b18067d3c086756a7feb050f017c093b764683f930c3

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