Skip to main content

A package to do everything from getting tweets to pre-processing

Project description

Tweetl

By using Tweetl, you can simplify the steps from getting tweets to pre-processing them. If you don't have twitter API key, you can get it here.

This package help you to ・・・

  • get tweets with the target name and any keywords.
  • pre-processes the following list.
    • remove hashtags, URLs, pictographs, mentions, image strings and RT.
    • unify characters (uppercase to lowercase, halfwidth forms to fullwidth forms).
    • replace number to zero.
    • remove duplicates (because they might be RT.)

Installation

pip install Tweetl

Usage

Getting Tweets

Create an instance of the 'GetTweet' Class.

import Tweetl

# your api keys
consumer_api_key = "xxxxxxxxx"
consumer_api_secret_key = "xxxxxxxxx"
access_token = "xxxxxxxxx"
access_token_secret = "xxxxxxxxx"

# create an instance
tweet_getter = Tweetl.GetTweet(
                    consumer_api_key,
                    consumer_api_secret_key, 
                    access_token, 
                    access_token_secret
                )

With target name

You can collect tweets of the target if you use 'get_tweets_target' method and set the target's name not inclueded '@'. Then it returns collected tweets as DataFrame type. And you can specify the number of tweets.

# get 1000 tweets of @Deepblue_ts
df_target = tweet_getter.get_tweets_target("Deepblue_ts", 1000)
df_target.head()
スクリーンショット 2020-05-22 14 33 39

With any keywords

You can also get tweets about any keywords if you use 'get_tweets_keyword' method and set any one. And you can specify the number of tweets.

# get 1000 tweets about 'deep learning'
df_keyword = tweet_getter.get_tweets_keyword("deep learning", 1000)

Cleansing Tweets

Create an instance of the 'CleansingTweets' Class. And using 'cleansing_df' method, you can pre-processing tweets. You can select columns that you want to cleanse. The default is only text-colmn.

# create an instance
tweet_cleanser = Tweetl.CleansingTweets()
cols = ["text", "user_description"]
df_clean = tweet_cleanser.cleansing_df(df_keyword, subset_cols=cols)

Author

deepblue

License

This software is released under the MIT License, see LICENSE.

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

Tweetl-0.0.7.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

Tweetl-0.0.7-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

Details for the file Tweetl-0.0.7.tar.gz.

File metadata

  • Download URL: Tweetl-0.0.7.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3

File hashes

Hashes for Tweetl-0.0.7.tar.gz
Algorithm Hash digest
SHA256 c288f66c73e939fc68f7e3d4b35fe00dcc7cc32a48f9473d5c44eb6dfd2ba801
MD5 a788a0054d439942065db2b95a07dfc6
BLAKE2b-256 013e6307862a4184256607ca5893f002652c9b0fa39ac90703b203d107e61703

See more details on using hashes here.

File details

Details for the file Tweetl-0.0.7-py3-none-any.whl.

File metadata

  • Download URL: Tweetl-0.0.7-py3-none-any.whl
  • Upload date:
  • Size: 5.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3

File hashes

Hashes for Tweetl-0.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 ab289b087fdbd17d5f992cff41594037bcfc5f36d976151c278e4e1426f72891
MD5 bd2fbe0dc40b4f9bfc44c071eec695a0
BLAKE2b-256 433efabdbc8bd1e8a7da12624a49d8ec69c43c6d1c6a4f0d1dfbb0dbeefb2067

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