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

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: tweepypoll-0.3.0.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.10.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

File hashes

Hashes for tweepypoll-0.3.0.tar.gz
Algorithm Hash digest
SHA256 af14c591f759b05ea234e7414e1fecb0f93f648097a40e3dbaa9b180ec2a30c1
MD5 ef9bdc3ba313a8a1e76e0b1c271e2215
BLAKE2b-256 da4b9debab3d471f0991bb515897d0415130d6b424192f92acf728f664445cb0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tweepypoll-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 6.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.10.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

File hashes

Hashes for tweepypoll-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 359d791fa64d540a14a61729c45a13d9e3d81efcdf4879c0b2056d37d56be9e0
MD5 d71abee6e26b54477dbef058ed2706e2
BLAKE2b-256 58326f2168ce48c9d89ffbefd5bd01ff92898b9585859f75d7f0060ef8ac0577

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