<jupyter_start><jupyter_text>Import some counts of tweets I collected using the `twarc filter demdebate`.<jupyter_code>import pandas

demdebate = pandas.read_csv('data/demdebate.csv', parse_dates=['time'])
demdebate.head()<jupyter_output><empty_output><jupyter_text>The granularity of a second is too fine for visualization. So let's try aggregating the counts by minute:<jupyter_code>import altair
altair.renderers.enable('notebook')

demdebate = demdebate.resample("1Min", on="time").sum().reset_index()
altair.Chart(demdebate, width=800).mark_line().encode(x='hoursminutes(time):T', y='tweets:Q')<jupyter_output><empty_output><jupyter_text>This graph plainly shows that we hit a maximum throughput of about 3,000 tweets per minute. It also shows that Twitter closed our filter stream around 2AM UTC, which twarc caught and quickly reopened its connection. But it lost a few tweets as a result. Dropped TweetsLegend has it (based on [old documentation](https://archive.is/X1XUZselection-781.0-799.212)) that Twitter's filter stream API will never deliver more than 1% of the total total tweets in a given second. Any tweets exceeding this amount will be "rate limited" or dropped.> If you're using the filter feature of the Streaming API, you'll be streamed Y tweets per "streaming second" that match your criteria, where Y tweets can never exceed 1% of X public tweets in the firehose during that same "streaming second." If there are more tweets that would match your criteria, you'll be streamed a rate limit message indicating how many tweets fell outside of 1%. Whether this legend is still true or not we can be sure that an event like the Democratic debate will be trigger any rate limits that might exist. In fact Twitter's [status/filter](https://developer.twitter.com/en/docs/tweets/filter-realtime/api-reference/post-statuses-filter.html) API endpoint will emit [Limit Notices](https://developer.twitter.com/en/docs/tweets/filter-realtime/guides/streaming-message-types) which are delivered right along with the tweets on the stream, and indicate how many tweets were undelivered.> These messages indicate that a filtered stream has matched more Tweets than its current rate limit allows to be delivered. Limit notices contain a total count of the number of undelivered Tweets since the connection was opened, making them useful for tracking counts of track terms, for example. Note that the counts do not specify which filter predicates undelivered messages matched.```json{  "limit": {    "track":1234  }}```twarc actually logs these messages as it encounters them. For example you will see messages like this in your log if your data collection is being limited:```2019-09-13 00:13:08,866 WARNING 51 tweets undelivered```So we can actually parse the log file and extract these counts to see how many tweets were dropped. Then we can add them to our graph to see if we can get a better sense of the volume of tweets.<jupyter_code>dropped = pandas.read_csv('data/demdebate-dropped.csv', parse_dates=['time'])
dropped = dropped.resample("1Min", on="time").sum().reset_index()

dropped.head(15)<jupyter_output><empty_output><jupyter_text>The tweets didn't start getting dropped until about 11 minutes into the debate, and then they continued to be dropped at varying rates until the end.<jupyter_code>altair.Chart(dropped, width=800).mark_line().encode(x='hoursminutes(time):T', y='tweets:Q')<jupyter_output><empty_output><jupyter_text>But maybe it would look better as an area chart to emphasize how much data was dropped? This involves a bit of reshaping of the data.<jupyter_code>from altair import Chart, Scale, Color, Axis, X, Y, Tooltip

demdebate2 = pandas.concat([
    pandas.DataFrame({'time': dropped['time'], 'tweets': dropped['tweets'], 'type': 'dropped'}),
    pandas.DataFrame({'time': demdebate['time'], 'tweets': demdebate['tweets'], 'type': 'received'})
])

Chart(demdebate2, width=800).mark_area().encode(
    X("hoursminutes(time):T", axis=Axis(title="Time (GMT)")),
    Y("tweets:Q", axis=Axis(title="Tweets per Minute")),
    Color('type:N',
        scale=Scale(domain=['dropped', 'received'],range=['#BB2266', '#11AA44'])
    ),
    Tooltip(['tweets', 'hoursminutes(time)'])
    
)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10270906949352179, 'fraction_numerical': 0.015783274440518257, 'mean_word_length': 5.80448717948718, 'pattern_counts': {'":': 2, '<': 21, '<?xml version=': 0, '>': 23, 'https://': 3, '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': '479603', 'license': 'CC-BY-4.0', 'n_tokens_mistral': 1325, 'n_tokens_neox': 1211, 'n_words': 479, 'path': 'DemDebate.ipynb', 'repo_name': 'edsu/notebooks', 'size': '4245'}