<jupyter_start><jupyter_text>Overview- import recent trending tweets using tweepy- run nlp model to identify police use of force  - limit to tweets to know hashtags with examples of police force for release 1- save scoped tweets into temp storage, ex: sqlite to avoid rate limits- run nlp/ner model on topic scoped tweets to find location of reported incident- use geopy or google rest api to get lat and lon of found gpe  tweepy config<jupyter_code>!pip install tweepy
import tweepy
import re
import plotly.express as px
import pandas as pd
API_KEY = input('api_key: ')
API_SECRET_KEY = input('api_secret_key: ')
auth = tweepy.OAuthHandler(API_KEY, API_SECRET_KEY)
api = tweepy.API(auth)<jupyter_output><empty_output><jupyter_text>scoped tweets to keywords "black lives matter<jupyter_code>blm_search = api.search("black lives matter",count=100)
def extract_hash_tags(s):
    return set(part[1:] for part in s.split() if part.startswith('#'))
blm_search.count
dir(blm_search)
hashtags = []
tweet_text = []
user_name = []
user_location = []
for i in blm_search:
  tweet_text.append(i.text)
  user_name.append(i.user.name)
  user_location.append(i.user.location)
  hashtags.append(extract_hash_tags(i.text))

df = pd.DataFrame({'user_name': user_name,
                   'user_location': user_location,
                   'tweet_text':tweet_text,
                   'tags': hashtags
                   })

df.head(10)<jupyter_output><empty_output><jupyter_text>nlp/ner: find location entities<jupyter_code># from google.colab import files
# uploaded = files.upload()
import spacy<jupyter_output><empty_output><jupyter_text>city to latitude and lon  twitter trends exploration<jupyter_code>trends = api.trends_available()
for i in trends[:1]:
  # print(dir(i))
  result = api.trends_place(i.get('woeid'))
from urllib.request import urlopen
import json
with urlopen('https://raw.githubusercontent.com/plotly/datasets/master/geojson-counties-fips.json') as response:
    counties = json.load(response)

counties["features"][0]<jupyter_output><empty_output><jupyter_text>Mapping<jupyter_code>px.choropleth(locations=["CA", "TX", "NY"], locationmode="USA-states", color=[1,2,3], scope="usa")
import plotly.graph_objects as go

import pandas as pd

df = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/2011_february_us_airport_traffic.csv')
df['text'] = df['airport'] + '' + df['city'] + ', ' + df['state'] + '' + 'Arrivals: ' + df['cnt'].astype(str)

fig = go.Figure(data=go.Scattergeo(
        lon = df['long'],
        lat = df['lat'],
        text = df['text'],
        mode = 'markers',
        marker_color = df['cnt'],
        ))

fig.update_layout(
        title = 'Most trafficked US airports<br>(Hover for airport names)',
        geo_scope='usa',
    )
fig.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12770485987938984, 'fraction_numerical': 0.005675771550195104, 'mean_word_length': 4.606361829025845, 'pattern_counts': {'":': 0, '<': 22, '<?xml version=': 0, '>': 22, 'https://': 2, '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': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '283370', 'license': 'MIT', 'n_tokens_mistral': 990, 'n_tokens_neox': 954, 'n_words': 219, 'path': 'notebooks/twitter/twitter_hrf.ipynb', 'repo_name': 'Lambda-School-Labs/Labs25-Human_Rights_First-TeamC-DS', 'size': '2819'}