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.2.tar.gz (6.0 kB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: tweepypoll-0.2.2.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.2.tar.gz
Algorithm Hash digest
SHA256 6ba135f3b8cd7ccf2aae97929fc86dccd8082eaa01eec37a14fa4d58b9728bc3
MD5 65449c1e7a9048b868de065b6815a927
BLAKE2b-256 7b163913d35ec3047e150d236b45ca46fb2d4c8053ffac9893b02b0082d1ea85

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tweepypoll-0.2.2-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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 7fe6b91cde37e5b1a1b779f63c23b50930463a4aa8eaa6d372132bedb2f2b458
MD5 aeab6616c65a04aa1992da3b02b0e0b1
BLAKE2b-256 c8a7f6fe15ef9efe1751a672d6e024783c06c8ed0290d9fa6400d6f192937659

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