<jupyter_start><jupyter_text><jupyter_code>#installing tweepy
!pip install tweepy
#loading libraries
import os
import tweepy as tw

#initializing the token keys
consumer_key = '91LtHt5fNCABkeWzDDqQZG7eN'
consumer_secret = '<KEY>'
access_token = '<KEY>'
access_token_secret = '<KEY>'


auth = tw.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
api = tw.API(auth,wait_on_rate_limit=True)
#inputing the search words and geo 
search_words = ["depression"]
date_since = "2010-01-01"
geo = '-0.023559,37.906193,300km'
tweets = tw.Cursor(api.search,
                       q=search_words,
                       lang="en",
                       geocode=geo,
                       since=date_since).items(1000)
tweets
#creating the data frame
import pandas as pd
user = [[tweet.user.screen_name,
         tweet.text,
         tweet.user.location,
         tweet.user.description,
         tweet.user.friends_count,
         tweet.user.followers_count,
         tweet.user.statuses_count,
         tweet.created_at,
         tweet.retweet_count, 
         tweet.entities['hashtags']] for tweet in tweets]
user

tweet_text = pd.DataFrame(data=users_locs, 
                    columns=['user', 'tweet',"location", 'description','friends_count','followers_count', 
                             'statuses_count', 'created_at', 'retweet_count', 'hashtags'])
tweet_text<jupyter_output><empty_output><jupyter_text><jupyter_code>tweet_text.tweet.head(1)
tweet_text['tweet']
tweet_text.to_csv("depression.csv")
tweet_text.created_at.unique()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11380597014925373, 'fraction_numerical': 0.021766169154228857, 'mean_word_length': 3.42032967032967, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '550020', 'license': 'MIT', 'n_tokens_mistral': 589, 'n_tokens_neox': 551, 'n_words': 88, 'path': 'TwitterScraper.ipynb', 'repo_name': 'BrianGisemba/MENTAL-HEALTH-TWEETS-CLASSIFICATION', 'size': '1738'}