651 lines
64 KiB
Text
651 lines
64 KiB
Text
|
{
|
|||
|
"cells": [
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"id": "d74b2c0a",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"## Twitter - Pressemitteilung Vergleich"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 2,
|
|||
|
"id": "8d048755",
|
|||
|
"metadata": {},
|
|||
|
"outputs": [],
|
|||
|
"source": [
|
|||
|
"import seaborn as sns\n",
|
|||
|
"import matplotlib.pyplot as plt\n",
|
|||
|
"\n",
|
|||
|
"import pandas as pd\n",
|
|||
|
"import numpy as np\n",
|
|||
|
"\n",
|
|||
|
"from tqdm import tqdm # Fortschrittsanzeige für pandas\n",
|
|||
|
"from datetime import datetime\n",
|
|||
|
"tqdm.pandas()"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 4,
|
|||
|
"id": "dc238dc3",
|
|||
|
"metadata": {},
|
|||
|
"outputs": [],
|
|||
|
"source": [
|
|||
|
"tweets_csv = '../mod_data/copbird_table_tweet_ext_state.csv'\n",
|
|||
|
"users_csv = '../mod_data/copbird_table_user_ext.csv'"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 5,
|
|||
|
"id": "88746ce4",
|
|||
|
"metadata": {},
|
|||
|
"outputs": [],
|
|||
|
"source": [
|
|||
|
"limit = None\n",
|
|||
|
"tweets = pd.read_csv(tweets_csv, nrows=limit)\n",
|
|||
|
"users = pd.read_csv(users_csv, nrows=limit)"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 6,
|
|||
|
"id": "a9d777a1",
|
|||
|
"metadata": {},
|
|||
|
"outputs": [
|
|||
|
{
|
|||
|
"data": {
|
|||
|
"text/html": [
|
|||
|
"<div>\n",
|
|||
|
"<style scoped>\n",
|
|||
|
" .dataframe tbody tr th:only-of-type {\n",
|
|||
|
" vertical-align: middle;\n",
|
|||
|
" }\n",
|
|||
|
"\n",
|
|||
|
" .dataframe tbody tr th {\n",
|
|||
|
" vertical-align: top;\n",
|
|||
|
" }\n",
|
|||
|
"\n",
|
|||
|
" .dataframe thead th {\n",
|
|||
|
" text-align: right;\n",
|
|||
|
" }\n",
|
|||
|
"</style>\n",
|
|||
|
"<table border=\"1\" class=\"dataframe\">\n",
|
|||
|
" <thead>\n",
|
|||
|
" <tr style=\"text-align: right;\">\n",
|
|||
|
" <th></th>\n",
|
|||
|
" <th>user_id</th>\n",
|
|||
|
" <th>name</th>\n",
|
|||
|
" <th>handle</th>\n",
|
|||
|
" <th>stadt</th>\n",
|
|||
|
" <th>bundesland</th>\n",
|
|||
|
" </tr>\n",
|
|||
|
" </thead>\n",
|
|||
|
" <tbody>\n",
|
|||
|
" <tr>\n",
|
|||
|
" <th>0</th>\n",
|
|||
|
" <td>1032561433102434304</td>\n",
|
|||
|
" <td>Polizei Wittlich</td>\n",
|
|||
|
" <td>PolizeiWittlich</td>\n",
|
|||
|
" <td>Wittlich</td>\n",
|
|||
|
" <td>Rheinland-Pfalz</td>\n",
|
|||
|
" </tr>\n",
|
|||
|
" <tr>\n",
|
|||
|
" <th>1</th>\n",
|
|||
|
" <td>1143867545226764293</td>\n",
|
|||
|
" <td>Bayerisches Landeskriminalamt</td>\n",
|
|||
|
" <td>LKA_Bayern</td>\n",
|
|||
|
" <td>München</td>\n",
|
|||
|
" <td>Bayern</td>\n",
|
|||
|
" </tr>\n",
|
|||
|
" <tr>\n",
|
|||
|
" <th>2</th>\n",
|
|||
|
" <td>1169206134189830145</td>\n",
|
|||
|
" <td>Polizei Stendal</td>\n",
|
|||
|
" <td>Polizei_SDL</td>\n",
|
|||
|
" <td>Stendal</td>\n",
|
|||
|
" <td>Sachsen-Anhalt</td>\n",
|
|||
|
" </tr>\n",
|
|||
|
" <tr>\n",
|
|||
|
" <th>3</th>\n",
|
|||
|
" <td>1184024283342950401</td>\n",
|
|||
|
" <td>Polizei Ravensburg</td>\n",
|
|||
|
" <td>PolizeiRV</td>\n",
|
|||
|
" <td>Ravensburg</td>\n",
|
|||
|
" <td>Baden-Württemberg</td>\n",
|
|||
|
" </tr>\n",
|
|||
|
" <tr>\n",
|
|||
|
" <th>4</th>\n",
|
|||
|
" <td>1232548941889228808</td>\n",
|
|||
|
" <td>Polizei Bad Nenndorf</td>\n",
|
|||
|
" <td>Polizei_BadN</td>\n",
|
|||
|
" <td>Bad Nenndorf</td>\n",
|
|||
|
" <td>Niedersachsen</td>\n",
|
|||
|
" </tr>\n",
|
|||
|
" </tbody>\n",
|
|||
|
"</table>\n",
|
|||
|
"</div>"
|
|||
|
],
|
|||
|
"text/plain": [
|
|||
|
" user_id name handle \\\n",
|
|||
|
"0 1032561433102434304 Polizei Wittlich PolizeiWittlich \n",
|
|||
|
"1 1143867545226764293 Bayerisches Landeskriminalamt LKA_Bayern \n",
|
|||
|
"2 1169206134189830145 Polizei Stendal Polizei_SDL \n",
|
|||
|
"3 1184024283342950401 Polizei Ravensburg PolizeiRV \n",
|
|||
|
"4 1232548941889228808 Polizei Bad Nenndorf Polizei_BadN \n",
|
|||
|
"\n",
|
|||
|
" stadt bundesland \n",
|
|||
|
"0 Wittlich Rheinland-Pfalz \n",
|
|||
|
"1 München Bayern \n",
|
|||
|
"2 Stendal Sachsen-Anhalt \n",
|
|||
|
"3 Ravensburg Baden-Württemberg \n",
|
|||
|
"4 Bad Nenndorf Niedersachsen "
|
|||
|
]
|
|||
|
},
|
|||
|
"execution_count": 6,
|
|||
|
"metadata": {},
|
|||
|
"output_type": "execute_result"
|
|||
|
}
|
|||
|
],
|
|||
|
"source": [
|
|||
|
"users.head()"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 7,
|
|||
|
"id": "f1cde0ae",
|
|||
|
"metadata": {},
|
|||
|
"outputs": [
|
|||
|
{
|
|||
|
"data": {
|
|||
|
"text/html": [
|
|||
|
"<div>\n",
|
|||
|
"<style scoped>\n",
|
|||
|
" .dataframe tbody tr th:only-of-type {\n",
|
|||
|
" vertical-align: middle;\n",
|
|||
|
" }\n",
|
|||
|
"\n",
|
|||
|
" .dataframe tbody tr th {\n",
|
|||
|
" vertical-align: top;\n",
|
|||
|
" }\n",
|
|||
|
"\n",
|
|||
|
" .dataframe thead th {\n",
|
|||
|
" text-align: right;\n",
|
|||
|
" }\n",
|
|||
|
"</style>\n",
|
|||
|
"<table border=\"1\" class=\"dataframe\">\n",
|
|||
|
" <thead>\n",
|
|||
|
" <tr style=\"text-align: right;\">\n",
|
|||
|
" <th></th>\n",
|
|||
|
" <th>tweet_id</th>\n",
|
|||
|
" <th>tweet_text</th>\n",
|
|||
|
" <th>created_at</th>\n",
|
|||
|
" <th>user_id</th>\n",
|
|||
|
" <th>user_name</th>\n",
|
|||
|
" <th>handle</th>\n",
|
|||
|
" <th>stadt</th>\n",
|
|||
|
" <th>bundesland</th>\n",
|
|||
|
" </tr>\n",
|
|||
|
" </thead>\n",
|
|||
|
" <tbody>\n",
|
|||
|
" <tr>\n",
|
|||
|
" <th>0</th>\n",
|
|||
|
" <td>1321021123463663616</td>\n",
|
|||
|
" <td>@mahanna196 Da die Stadt keine Ausnahme für Ra...</td>\n",
|
|||
|
" <td>2020-10-27 09:29:13</td>\n",
|
|||
|
" <td>778895426007203840</td>\n",
|
|||
|
" <td>Polizei Oldenburg-Stadt/Ammerl</td>\n",
|
|||
|
" <td>Polizei_OL</td>\n",
|
|||
|
" <td>NaN</td>\n",
|
|||
|
" <td>NaN</td>\n",
|
|||
|
" </tr>\n",
|
|||
|
" <tr>\n",
|
|||
|
" <th>1</th>\n",
|
|||
|
" <td>1321023114071969792</td>\n",
|
|||
|
" <td>#Zeugengesucht\\r\\nDie Hintergründe zu dem Tötu...</td>\n",
|
|||
|
" <td>2020-10-27 09:37:08</td>\n",
|
|||
|
" <td>2397974054</td>\n",
|
|||
|
" <td>Polizei Berlin</td>\n",
|
|||
|
" <td>polizeiberlin</td>\n",
|
|||
|
" <td>Berlin</td>\n",
|
|||
|
" <td>Berlin</td>\n",
|
|||
|
" </tr>\n",
|
|||
|
" <tr>\n",
|
|||
|
" <th>2</th>\n",
|
|||
|
" <td>1321025127388188673</td>\n",
|
|||
|
" <td>RT @bka: EUROPE´S MOST WANTED – Sexualstraftät...</td>\n",
|
|||
|
" <td>2020-10-27 09:45:08</td>\n",
|
|||
|
" <td>2397974054</td>\n",
|
|||
|
" <td>Polizei Berlin</td>\n",
|
|||
|
" <td>polizeiberlin</td>\n",
|
|||
|
" <td>Berlin</td>\n",
|
|||
|
" <td>Berlin</td>\n",
|
|||
|
" </tr>\n",
|
|||
|
" <tr>\n",
|
|||
|
" <th>3</th>\n",
|
|||
|
" <td>1321028108665950208</td>\n",
|
|||
|
" <td>@StrupeitVolker Wir verstehen nicht so recht w...</td>\n",
|
|||
|
" <td>2020-10-27 09:56:59</td>\n",
|
|||
|
" <td>2810902381</td>\n",
|
|||
|
" <td>Polizei München</td>\n",
|
|||
|
" <td>PolizeiMuenchen</td>\n",
|
|||
|
" <td>München</td>\n",
|
|||
|
" <td>Bayern</td>\n",
|
|||
|
" </tr>\n",
|
|||
|
" <tr>\n",
|
|||
|
" <th>4</th>\n",
|
|||
|
" <td>1321029199998656513</td>\n",
|
|||
|
" <td>Wir unterstützen das @bka bei der #Öffentlichk...</td>\n",
|
|||
|
" <td>2020-10-27 10:01:19</td>\n",
|
|||
|
" <td>223758384</td>\n",
|
|||
|
" <td>Polizei Sachsen</td>\n",
|
|||
|
" <td>PolizeiSachsen</td>\n",
|
|||
|
" <td>Dresden</td>\n",
|
|||
|
" <td>Sachsen</td>\n",
|
|||
|
" </tr>\n",
|
|||
|
" </tbody>\n",
|
|||
|
"</table>\n",
|
|||
|
"</div>"
|
|||
|
],
|
|||
|
"text/plain": [
|
|||
|
" tweet_id tweet_text \\\n",
|
|||
|
"0 1321021123463663616 @mahanna196 Da die Stadt keine Ausnahme für Ra... \n",
|
|||
|
"1 1321023114071969792 #Zeugengesucht\\r\\nDie Hintergründe zu dem Tötu... \n",
|
|||
|
"2 1321025127388188673 RT @bka: EUROPE´S MOST WANTED – Sexualstraftät... \n",
|
|||
|
"3 1321028108665950208 @StrupeitVolker Wir verstehen nicht so recht w... \n",
|
|||
|
"4 1321029199998656513 Wir unterstützen das @bka bei der #Öffentlichk... \n",
|
|||
|
"\n",
|
|||
|
" created_at user_id user_name \\\n",
|
|||
|
"0 2020-10-27 09:29:13 778895426007203840 Polizei Oldenburg-Stadt/Ammerl \n",
|
|||
|
"1 2020-10-27 09:37:08 2397974054 Polizei Berlin \n",
|
|||
|
"2 2020-10-27 09:45:08 2397974054 Polizei Berlin \n",
|
|||
|
"3 2020-10-27 09:56:59 2810902381 Polizei München \n",
|
|||
|
"4 2020-10-27 10:01:19 223758384 Polizei Sachsen \n",
|
|||
|
"\n",
|
|||
|
" handle stadt bundesland \n",
|
|||
|
"0 Polizei_OL NaN NaN \n",
|
|||
|
"1 polizeiberlin Berlin Berlin \n",
|
|||
|
"2 polizeiberlin Berlin Berlin \n",
|
|||
|
"3 PolizeiMuenchen München Bayern \n",
|
|||
|
"4 PolizeiSachsen Dresden Sachsen "
|
|||
|
]
|
|||
|
},
|
|||
|
"execution_count": 7,
|
|||
|
"metadata": {},
|
|||
|
"output_type": "execute_result"
|
|||
|
}
|
|||
|
],
|
|||
|
"source": [
|
|||
|
"tweets.head()"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"id": "ce184d1d",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"Selektiere Tweets mit PM-Links"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 8,
|
|||
|
"id": "5e20da3c",
|
|||
|
"metadata": {},
|
|||
|
"outputs": [],
|
|||
|
"source": [
|
|||
|
"def has_pm_link(txt):\n",
|
|||
|
" return \"https://t.co/\" in txt"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 9,
|
|||
|
"id": "7902d91c",
|
|||
|
"metadata": {},
|
|||
|
"outputs": [],
|
|||
|
"source": [
|
|||
|
"tweets['has_pm'] = tweets['tweet_text'].apply(lambda x: has_pm_link(x))"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 10,
|
|||
|
"id": "fe6a144e",
|
|||
|
"metadata": {},
|
|||
|
"outputs": [
|
|||
|
{
|
|||
|
"data": {
|
|||
|
"text/html": [
|
|||
|
"<div>\n",
|
|||
|
"<style scoped>\n",
|
|||
|
" .dataframe tbody tr th:only-of-type {\n",
|
|||
|
" vertical-align: middle;\n",
|
|||
|
" }\n",
|
|||
|
"\n",
|
|||
|
" .dataframe tbody tr th {\n",
|
|||
|
" vertical-align: top;\n",
|
|||
|
" }\n",
|
|||
|
"\n",
|
|||
|
" .dataframe thead th {\n",
|
|||
|
" text-align: right;\n",
|
|||
|
" }\n",
|
|||
|
"</style>\n",
|
|||
|
"<table border=\"1\" class=\"dataframe\">\n",
|
|||
|
" <thead>\n",
|
|||
|
" <tr style=\"text-align: right;\">\n",
|
|||
|
" <th></th>\n",
|
|||
|
" <th>tweet_id</th>\n",
|
|||
|
" <th>tweet_text</th>\n",
|
|||
|
" <th>created_at</th>\n",
|
|||
|
" <th>user_id</th>\n",
|
|||
|
" <th>user_name</th>\n",
|
|||
|
" <th>handle</th>\n",
|
|||
|
" <th>stadt</th>\n",
|
|||
|
" <th>bundesland</th>\n",
|
|||
|
" <th>has_pm</th>\n",
|
|||
|
" </tr>\n",
|
|||
|
" </thead>\n",
|
|||
|
" <tbody>\n",
|
|||
|
" <tr>\n",
|
|||
|
" <th>0</th>\n",
|
|||
|
" <td>1321021123463663616</td>\n",
|
|||
|
" <td>@mahanna196 Da die Stadt keine Ausnahme für Ra...</td>\n",
|
|||
|
" <td>2020-10-27 09:29:13</td>\n",
|
|||
|
" <td>778895426007203840</td>\n",
|
|||
|
" <td>Polizei Oldenburg-Stadt/Ammerl</td>\n",
|
|||
|
" <td>Polizei_OL</td>\n",
|
|||
|
" <td>NaN</td>\n",
|
|||
|
" <td>NaN</td>\n",
|
|||
|
" <td>False</td>\n",
|
|||
|
" </tr>\n",
|
|||
|
" <tr>\n",
|
|||
|
" <th>1</th>\n",
|
|||
|
" <td>1321023114071969792</td>\n",
|
|||
|
" <td>#Zeugengesucht\\r\\nDie Hintergründe zu dem Tötu...</td>\n",
|
|||
|
" <td>2020-10-27 09:37:08</td>\n",
|
|||
|
" <td>2397974054</td>\n",
|
|||
|
" <td>Polizei Berlin</td>\n",
|
|||
|
" <td>polizeiberlin</td>\n",
|
|||
|
" <td>Berlin</td>\n",
|
|||
|
" <td>Berlin</td>\n",
|
|||
|
" <td>True</td>\n",
|
|||
|
" </tr>\n",
|
|||
|
" <tr>\n",
|
|||
|
" <th>2</th>\n",
|
|||
|
" <td>1321025127388188673</td>\n",
|
|||
|
" <td>RT @bka: EUROPE´S MOST WANTED – Sexualstraftät...</td>\n",
|
|||
|
" <td>2020-10-27 09:45:08</td>\n",
|
|||
|
" <td>2397974054</td>\n",
|
|||
|
" <td>Polizei Berlin</td>\n",
|
|||
|
" <td>polizeiberlin</td>\n",
|
|||
|
" <td>Berlin</td>\n",
|
|||
|
" <td>Berlin</td>\n",
|
|||
|
" <td>True</td>\n",
|
|||
|
" </tr>\n",
|
|||
|
" <tr>\n",
|
|||
|
" <th>3</th>\n",
|
|||
|
" <td>1321028108665950208</td>\n",
|
|||
|
" <td>@StrupeitVolker Wir verstehen nicht so recht w...</td>\n",
|
|||
|
" <td>2020-10-27 09:56:59</td>\n",
|
|||
|
" <td>2810902381</td>\n",
|
|||
|
" <td>Polizei München</td>\n",
|
|||
|
" <td>PolizeiMuenchen</td>\n",
|
|||
|
" <td>München</td>\n",
|
|||
|
" <td>Bayern</td>\n",
|
|||
|
" <td>False</td>\n",
|
|||
|
" </tr>\n",
|
|||
|
" <tr>\n",
|
|||
|
" <th>4</th>\n",
|
|||
|
" <td>1321029199998656513</td>\n",
|
|||
|
" <td>Wir unterstützen das @bka bei der #Öffentlichk...</td>\n",
|
|||
|
" <td>2020-10-27 10:01:19</td>\n",
|
|||
|
" <td>223758384</td>\n",
|
|||
|
" <td>Polizei Sachsen</td>\n",
|
|||
|
" <td>PolizeiSachsen</td>\n",
|
|||
|
" <td>Dresden</td>\n",
|
|||
|
" <td>Sachsen</td>\n",
|
|||
|
" <td>True</td>\n",
|
|||
|
" </tr>\n",
|
|||
|
" </tbody>\n",
|
|||
|
"</table>\n",
|
|||
|
"</div>"
|
|||
|
],
|
|||
|
"text/plain": [
|
|||
|
" tweet_id tweet_text \\\n",
|
|||
|
"0 1321021123463663616 @mahanna196 Da die Stadt keine Ausnahme für Ra... \n",
|
|||
|
"1 1321023114071969792 #Zeugengesucht\\r\\nDie Hintergründe zu dem Tötu... \n",
|
|||
|
"2 1321025127388188673 RT @bka: EUROPE´S MOST WANTED – Sexualstraftät... \n",
|
|||
|
"3 1321028108665950208 @StrupeitVolker Wir verstehen nicht so recht w... \n",
|
|||
|
"4 1321029199998656513 Wir unterstützen das @bka bei der #Öffentlichk... \n",
|
|||
|
"\n",
|
|||
|
" created_at user_id user_name \\\n",
|
|||
|
"0 2020-10-27 09:29:13 778895426007203840 Polizei Oldenburg-Stadt/Ammerl \n",
|
|||
|
"1 2020-10-27 09:37:08 2397974054 Polizei Berlin \n",
|
|||
|
"2 2020-10-27 09:45:08 2397974054 Polizei Berlin \n",
|
|||
|
"3 2020-10-27 09:56:59 2810902381 Polizei München \n",
|
|||
|
"4 2020-10-27 10:01:19 223758384 Polizei Sachsen \n",
|
|||
|
"\n",
|
|||
|
" handle stadt bundesland has_pm \n",
|
|||
|
"0 Polizei_OL NaN NaN False \n",
|
|||
|
"1 polizeiberlin Berlin Berlin True \n",
|
|||
|
"2 polizeiberlin Berlin Berlin True \n",
|
|||
|
"3 PolizeiMuenchen München Bayern False \n",
|
|||
|
"4 PolizeiSachsen Dresden Sachsen True "
|
|||
|
]
|
|||
|
},
|
|||
|
"execution_count": 10,
|
|||
|
"metadata": {},
|
|||
|
"output_type": "execute_result"
|
|||
|
}
|
|||
|
],
|
|||
|
"source": [
|
|||
|
"tweets.head()"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"id": "09c2ed78",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"Erzeuge einen gesamten DataFrame"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 12,
|
|||
|
"id": "299ab987",
|
|||
|
"metadata": {},
|
|||
|
"outputs": [],
|
|||
|
"source": [
|
|||
|
"tweets_with_pm = tweets.loc[tweets['has_pm'] == True]\n",
|
|||
|
"tweets_without_pm = tweets.loc[tweets['has_pm'] == False]"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 13,
|
|||
|
"id": "41cf83cb",
|
|||
|
"metadata": {},
|
|||
|
"outputs": [],
|
|||
|
"source": [
|
|||
|
"tweets_with_pm_count = tweets_with_pm.groupby('bundesland').size().reset_index(name='count').sort_values(by='count', ascending=False)\n",
|
|||
|
"tweets_without_pm_count = tweets_without_pm.groupby('bundesland').size().reset_index(name='count').sort_values(by='count', ascending=False)"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 14,
|
|||
|
"id": "8fc83c56",
|
|||
|
"metadata": {},
|
|||
|
"outputs": [],
|
|||
|
"source": [
|
|||
|
"tweets_with_pm_count['pm'] = tweets_with_pm_count['count'].apply(lambda x: 'mit PM')\n",
|
|||
|
"tweets_without_pm_count['pm'] = tweets_with_pm_count['count'].apply(lambda x: 'ohne PM')"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 15,
|
|||
|
"id": "a674d7e3",
|
|||
|
"metadata": {},
|
|||
|
"outputs": [],
|
|||
|
"source": [
|
|||
|
"result = pd.concat([tweets_with_pm_count, tweets_without_pm_count])"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 16,
|
|||
|
"id": "7ca5c2a2",
|
|||
|
"metadata": {},
|
|||
|
"outputs": [
|
|||
|
{
|
|||
|
"data": {
|
|||
|
"text/html": [
|
|||
|
"<div>\n",
|
|||
|
"<style scoped>\n",
|
|||
|
" .dataframe tbody tr th:only-of-type {\n",
|
|||
|
" vertical-align: middle;\n",
|
|||
|
" }\n",
|
|||
|
"\n",
|
|||
|
" .dataframe tbody tr th {\n",
|
|||
|
" vertical-align: top;\n",
|
|||
|
" }\n",
|
|||
|
"\n",
|
|||
|
" .dataframe thead th {\n",
|
|||
|
" text-align: right;\n",
|
|||
|
" }\n",
|
|||
|
"</style>\n",
|
|||
|
"<table border=\"1\" class=\"dataframe\">\n",
|
|||
|
" <thead>\n",
|
|||
|
" <tr style=\"text-align: right;\">\n",
|
|||
|
" <th></th>\n",
|
|||
|
" <th>bundesland</th>\n",
|
|||
|
" <th>count</th>\n",
|
|||
|
" <th>pm</th>\n",
|
|||
|
" </tr>\n",
|
|||
|
" </thead>\n",
|
|||
|
" <tbody>\n",
|
|||
|
" <tr>\n",
|
|||
|
" <th>10</th>\n",
|
|||
|
" <td>Nordrhein-Westfalen</td>\n",
|
|||
|
" <td>9242</td>\n",
|
|||
|
" <td>mit PM</td>\n",
|
|||
|
" </tr>\n",
|
|||
|
" <tr>\n",
|
|||
|
" <th>9</th>\n",
|
|||
|
" <td>Niedersachsen</td>\n",
|
|||
|
" <td>2773</td>\n",
|
|||
|
" <td>mit PM</td>\n",
|
|||
|
" </tr>\n",
|
|||
|
" <tr>\n",
|
|||
|
" <th>1</th>\n",
|
|||
|
" <td>Baden-Württemberg</td>\n",
|
|||
|
" <td>2759</td>\n",
|
|||
|
" <td>mit PM</td>\n",
|
|||
|
" </tr>\n",
|
|||
|
" <tr>\n",
|
|||
|
" <th>2</th>\n",
|
|||
|
" <td>Bayern</td>\n",
|
|||
|
" <td>2264</td>\n",
|
|||
|
" <td>mit PM</td>\n",
|
|||
|
" </tr>\n",
|
|||
|
" <tr>\n",
|
|||
|
" <th>7</th>\n",
|
|||
|
" <td>Hessen</td>\n",
|
|||
|
" <td>1737</td>\n",
|
|||
|
" <td>mit PM</td>\n",
|
|||
|
" </tr>\n",
|
|||
|
" </tbody>\n",
|
|||
|
"</table>\n",
|
|||
|
"</div>"
|
|||
|
],
|
|||
|
"text/plain": [
|
|||
|
" bundesland count pm\n",
|
|||
|
"10 Nordrhein-Westfalen 9242 mit PM\n",
|
|||
|
"9 Niedersachsen 2773 mit PM\n",
|
|||
|
"1 Baden-Württemberg 2759 mit PM\n",
|
|||
|
"2 Bayern 2264 mit PM\n",
|
|||
|
"7 Hessen 1737 mit PM"
|
|||
|
]
|
|||
|
},
|
|||
|
"execution_count": 16,
|
|||
|
"metadata": {},
|
|||
|
"output_type": "execute_result"
|
|||
|
}
|
|||
|
],
|
|||
|
"source": [
|
|||
|
"result.head()"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"id": "e1185d0c",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"Visualisiere die Ergebnisse"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 20,
|
|||
|
"id": "ad21d5c9",
|
|||
|
"metadata": {},
|
|||
|
"outputs": [
|
|||
|
{
|
|||
|
"data": {
|
|||
|
"text/plain": [
|
|||
|
"[]"
|
|||
|
]
|
|||
|
},
|
|||
|
"execution_count": 20,
|
|||
|
"metadata": {},
|
|||
|
"output_type": "execute_result"
|
|||
|
},
|
|||
|
{
|
|||
|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fXYrbOVVWqVVyxaNcq558xfmvXfnNcq5AACAxtVu1RVSvULLRj9vzYL5mTl7wRf62jfemJrDD/95brllbKNmOvPMUzNx4hNZZZVVkyQLFy7IgAG7Z+DAPfK3vz2ZI444KD//+aHZe+/96r7mgQfuywknHJtf//rSfOc73b50BmW3wlq1bJFBQ65tlHNdN2pw3ouyCwAATVH1Ci0zcdQBjX7ezYdcnuSLld1l6YADDsoPf9gvSfLOO29n0KDdsvHGmyZJOnbslPvum1Cv7P7lL3enbdt2jfbnK7sAAADLgd///srcffedadasWbbYomcOOeSIJMn8+fNzyinH55//fDkrr7xKzjrr3Ky6atvssssO+e53v5enn/6/NG9endNPPytf//oamTTp2fz61+dl/vx5WXXVtjnuuBPy9a+v8Zl/dvv2HbLmmt/Mv//977Rt2zZrrPGNzJnzfqZOnZKvf32NzJs3L1Onvp5vfWvtRvt+zdkFAAAouUcffSgPPfRArrjimlx55bWZMuXfGTPmj0mSWbNmZo89Bueaa25K+/btc889dydJ3n777Wy+eff87nfXZZNNNssf/3hTFi5cmLPPHpFTTjkzV155bfbcc6+MHHnm5/75L774Qv7971fz3/+9Qd2x7bbbPvfd95ckySOPPJQtt+zdqN+zO7sAAAAlN3Hik9l++x3SsmWrJEnfvjvnzjvvyFZb9c7XvtYxG2ywUZJk7bW7ZPbsWXVf16PHlkmSddbpkqee+nv+/e9XM3Xq6xk27H/rPmfOnDmf+mdefvmluemm67N48aK0bNkqxx03PKuv/vW88cbUJEmfPt/P6aeflEGD9smECXfnZz87JH/725ON9j0ruwAAACVXW7v4Y4+TRYtqkiTNmzf/2Mdq637fsuWHC2pVVVWltrY2ixYtzte/vkauuuq6JMmiRYsyc+Y7n/pnfnTO7qf5xjfWTE1NTf71r39m+vTpWWutby319/VZDGMGAAAoue98Z4vcc89dmT9/XmpqajJu3O1faMXjtdb6Vt5999089dTfkyR33HF7Tj11+BfOtd1238vIkSPSu/c2X/gc/4k7uwAAACXXq9fWefHF57P//vtk0aKa9OixZQYO3CMzZkxfqvOssMIKOeOMs/OrX52bBQsWZMUVV8qJJ572hXP16fP9/OY3F+Wkk07/wuf4T6pqP3qPuoTefvv9LF7cdL/Fjh1XbtSth2bMeK9RzgUAAHw5b775alZbba26x01xn90i+fjfZ7NmVenQoc1//Hx3dgEAAL4CHxbS8pfSpsKcXQAAAEpH2QUAAKB0lF0AAIBlpORLJH1lPtw6qWqpvkbZBQAAWAaqq1fInDnvKrxfQm1tbWpqFmbWrLeywgqtluprLVAFAACwDLRr1zEzZ87I++/PqnSUQmvWrHlat26TNm1WXaqvU3YBAACWgebNq/O1r61e6RjLLcOYAQAAKB1lFwAAgNJRdgEAACgdZRcAAIDSUXYBAAAoHWUXAACA0lF2AQAAKB1lFwAAgNJRdgEAACgdZRcAAIDSUXYBAAAoHWUXAACA0lF2AQAAKB1lFwAAgNJRdgEAACgdZRcAAIDSUXYBAAAoHWUXAACA0lF2AQAAKB1lFwAAgNJRdgEAACgdZRcAAIDSUXYBAAAoHWUXAACA0lF2AQAAKB1lFwAAgNJRdgEAACgdZRcAAIDSUXYBAAAoHWUXAACA0lF2AQAAKB1lFwAAgNJRdgEAACgdZRcAAIDSUXYBAAAoHWUXAACA0lF2AQAAKB1lFwAAgNJRdgEAACgdZRcAAIDSUXYBAAAoHWUXAACA0lF2AQAAKB1lFwAAgNJRdgEAACgdZRcAAIDSUXYBAAAoHWUXAAC
|
|||
|
"text/plain": [
|
|||
|
"<Figure size 1152x1152 with 1 Axes>"
|
|||
|
]
|
|||
|
},
|
|||
|
"metadata": {},
|
|||
|
"output_type": "display_data"
|
|||
|
}
|
|||
|
],
|
|||
|
"source": [
|
|||
|
"sns.set(style=\"darkgrid\")\n",
|
|||
|
"plt.figure(figsize=(16, 16))\n",
|
|||
|
"g = sns.barplot(x=\"bundesland\", y=\"count\", hue=\"pm\", data=result, ci=None)\n",
|
|||
|
"g.set_xticklabels(g.get_xticklabels(), rotation=90, ha='right')\n",
|
|||
|
"plt.plot()"
|
|||
|
]
|
|||
|
}
|
|||
|
],
|
|||
|
"metadata": {
|
|||
|
"kernelspec": {
|
|||
|
"display_name": "copbird-env",
|
|||
|
"language": "python",
|
|||
|
"name": "copbird-env"
|
|||
|
},
|
|||
|
"language_info": {
|
|||
|
"codemirror_mode": {
|
|||
|
"name": "ipython",
|
|||
|
"version": 3
|
|||
|
},
|
|||
|
"file_extension": ".py",
|
|||
|
"mimetype": "text/x-python",
|
|||
|
"name": "python",
|
|||
|
"nbconvert_exporter": "python",
|
|||
|
"pygments_lexer": "ipython3",
|
|||
|
"version": "3.8.5"
|
|||
|
}
|
|||
|
},
|
|||
|
"nbformat": 4,
|
|||
|
"nbformat_minor": 5
|
|||
|
}
|