aki_prj23_transparenzregister/Jupyter/connection-counter.ipynb
Philipp Horstenkamp a9304201af
(chore): Initilised devops tools (#29)
* Added a first action

* Repaired a typo

* Repaired a typo2

* Repaired a typo2

* Added flake8 action

* Repaired a typo in the flake8 action.

* Added a first bandit action

* Added a first batch

* Added a first batch

* Added a first batch

* Added a first batch

* Added a first batch

* Added the flake8-prebuild as a need to flake8

* Added the flake8-prebuild as a need to flake8

* Added the flake8-prebuild as a need to flake8

* Added the docker socket to the volume.

* Added the flake8-prebuild as a need to flake8

* Removed latest part from container.

* Removed latest part from container.

* Removed latest part from container.

* Reworked flake8

* Reworked flake8

* Reworked flake8

* Reworked flake8

* Reworked flake8

* Reworked flake8

* Reworked flake8

* Reworked flake8

* Reworked flake8

* Reworked flake8

* Reworked flake8

* Reworked flake8

* Reworked flake8 poetry

* Reworked flake8 poetry

* Changed to 64bit

* Some edits to the runner

* Added python setup

* Added python -m to python docker image.

* Added python -m to python docker image.

* Added python -m to python docker image.

* Added python -m to python docker image.

* Added python -m to python docker image.

* Added python -m to python docker image.

* Added ra run linter

* Added ra run linter

* Added ra run linter

* Added ra run linter

* Removed redundant version

* Removed redundant version

* Added isort

* Added isort

* Added isort

* Added poetry install

* Added poetry install

* Added flake8 as lint.

* Added flake8 as lint.

* Added flake8 as lint.

* Added flake8 as lint.

* Added flake8 as lint.

* Added flake8 as lint.

* Added flake8 as lint.

* Uses nodejs and python image

* Added flake8 as lint.

* Added flake8 as lint.

* Added flake8 as lint.

* Added flake8 as lint.

* Removed selfhosted runner

* Removed self hosted runner

* Removed self hosted runner

* Removed self hosted runner

* Added black and flake8 tests

* Removed self hosted runner

* Removed self hosted runner

* Removed unneded actions

* Added a mypy error.

* Removed poetry call before boetry setup

* Removed poetry call before poetry setup

* Added a test to understand the poetry action better

* Added a test to understand the poetry action better

* Added a test to understand the poetry action better

* Added a test to understand the poetry action better

* Added a test to understand the poetry action better

* Added a test to understand the poetry action better

* Added the snook poetry builder

* Reworked the repo a bit

* Removed unneeded poetry installation

* Added the isort action

* Added isort test

* Added ruff

* Added full ruff configuration

* Added full ruff configuration2

* Added full ruff configuration2

* Removed duplicat configurations

* Removed some redundant pre-commit hooks

* Removed unneeded actions.

* Removed unneeded actions.

* Repaired ruff

* Added tests.

* Removed

* Removed

* Removed a missing file

* Removed a missing file

* Removed a missing file

* Removed a missing file

* Removed a missing file

* Added reports as artifacts

* Added reports as artifacts

* Added reports as artifacts

* Removed the unneded poetry test

* Added a license checker.

* Added a license checker.

* Removed some unneeded configuration.

* Removed the import reformatted.

* Added doc generation.

* Added doc generation.

* Added license summary.

* Add

* Add lint

* Switched pip-licenses to poetry.

* Switched pip-licenses to poetry.

* Switched pip-licenses to poetry.

* Remove some more packages.

* Remove some more packages.

* Added a make file

* Added a make file

* Added a make file

* Added a make file

* Added a make file

* Added a make file

* Added a make file

* Added a make file

* Added a make file

* Added a make file

* Added a make file

* Added a make file

* Added a make file

* Added a make file

* Added a make file

* Added version codes to the main package

* Changed the format of the md files

* Presentation first draft

* Version up and added extensions

* Version up and added extensions

* Version up and added extensions

* Removed the venv path from docbuild

* Actions version up

* Actions version up

* Actions version up

* Actions version up

* Actions version up

* Actions version up

* Experiements with sphinx

* Experiments with sphinx

* Experiments with sphinx

* Experiments with sphinx

* Experiments with sphinx

* Experiments with sphinx

* Experiments with sphinx

* Experiments with sphinx

* First draft of the sphinx documentation.

* Added the protocol to the time series.

* Added the protocol to the time series.

* First draft ot a first build pipline

* Added mermaid version support

* Added documentations pull and branch request requirements.

* Added documentations pull and branch request requirements.

* Added documentations pull and branch request requirements.

* Added documentations pull and branch request requirements.

* Tests should now be passing

* Tests should now be passing

* Tests should now be passing

* Tests should now be passing

* Tests should now be passing

* Tests should now be passing

* Tests should now be passing

* Tests should now be passing

* Add safety

* Add safety

* Add safety

* Added the action on pull_request_target

* Added the action on pull_request_target

* Added the action on pull_request_target

* Added a pytest coverage report

* Added a pytest coverage report

* Added a pytest coverage report

* Added a pytest coverage report

* Added a pytest coverage report

* Added a build step

* Added a build step

* Added a build step

* Added a build step

* Changed the lint action to work only on python changes.

* Changed the lint action to work only on python changes.

* Changed the lint action to work only on python changes.

* Added the ability to compile a html report

* Added the ability to compile a html report

* Added the ability to compile a html report

* Added the ability to compile a html report

* Added the ability to compile a html report

* Added the ability to compile a html report

* Added the ability to compile a html report

* Added the ability to compile a html report

* Added the ability to compile a html report

* Added the ability to compile a html report

* Added the ability to compile a html report

* Added the ability to compile a html report

* Added the ability to compile a html report

* Added the ability to compile a html report

* Added the ability to compile a html report

* Coverage

* Finished test and build workflow

* Finished test and build workflow

* Finished test and build workflow

* Finished test and build workflow

* Finished test and build workflow

* Finished test and build workflow

* Finished test and build workflow

* Finished test and build workflow

* Finished test and build workflow

* Finished test and build workflow

* Finished test and build workflow

* Finished test and build workflow

* Finished test and build workflow

* Finished test and build workflow

* Finished test and build workflow

* Finished test and build workflow

* Finished test and build workflow

* Finished test and build workflow

* Finished test and build workflow

* Finished test and build workflow

* Repaired a bug.

* Repaired a bug.

* Repaired a bug.

* Repaired a bug.

* Repaired a bug.

* Added a github branch.ref

* Removed a poetry install

* Docbuild now excludes templates

* Added the seminarpräsentation to the documentation build

* Added the seminarpräsentation to the documentation build

* Added the seminarpräsentation to the documentation build

* dded a few images

* Changed the pre-commit image

* Changed the pre-commit image

* Presentation done

* Never executing jupyter for sphinx

* Never executing jupyter for sphinx

* Never executing jupyter for sphinx

* Never executing jupyter for sphinx

* Never executing jupyter for sphinx
2023-06-23 18:47:04 +02:00

237 lines
13 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{
"cells": [
{
"cell_type": "code",
"execution_count": 54,
"metadata": {
"collapsed": true,
"ExecuteTime": {
"end_time": "2023-06-03T01:36:32.345509400Z",
"start_time": "2023-06-03T01:36:32.332130700Z"
}
},
"outputs": [],
"source": [
"from typing import Final\n",
"\n",
"import numpy as np\n",
"import pandas as pd"
]
},
{
"cell_type": "code",
"execution_count": 1,
"outputs": [
{
"data": {
"text/plain": " Company 1 Connection Weight Company 2\n0 21 83 58\n1 37 88 86\n2 40 6 83\n3 60 35 2\n4 11 22 10\n.. ... ... ...\n695 62 37 11\n696 10 24 27\n697 97 40 55\n698 14 87 66\n699 50 55 82\n\n[693 rows x 3 columns]",
"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>Company 1</th>\n <th>Connection Weight</th>\n <th>Company 2</th>\n </tr>\n </thead>\n <tbody>\n <tr>\n <th>0</th>\n <td>21</td>\n <td>83</td>\n <td>58</td>\n </tr>\n <tr>\n <th>1</th>\n <td>37</td>\n <td>88</td>\n <td>86</td>\n </tr>\n <tr>\n <th>2</th>\n <td>40</td>\n <td>6</td>\n <td>83</td>\n </tr>\n <tr>\n <th>3</th>\n <td>60</td>\n <td>35</td>\n <td>2</td>\n </tr>\n <tr>\n <th>4</th>\n <td>11</td>\n <td>22</td>\n <td>10</td>\n </tr>\n <tr>\n <th>...</th>\n <td>...</td>\n <td>...</td>\n <td>...</td>\n </tr>\n <tr>\n <th>695</th>\n <td>62</td>\n <td>37</td>\n <td>11</td>\n </tr>\n <tr>\n <th>696</th>\n <td>10</td>\n <td>24</td>\n <td>27</td>\n </tr>\n <tr>\n <th>697</th>\n <td>97</td>\n <td>40</td>\n <td>55</td>\n </tr>\n <tr>\n <th>698</th>\n <td>14</td>\n <td>87</td>\n <td>66</td>\n </tr>\n <tr>\n <th>699</th>\n <td>50</td>\n <td>55</td>\n <td>82</td>\n </tr>\n </tbody>\n</table>\n<p>693 rows × 3 columns</p>\n</div>"
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from typing import Final\n",
"\n",
"import numpy as np\n",
"import pandas as pd\n",
"\n",
"number_of_entries = 100\n",
"number_of_contacts = 10\n",
"ids: Final = [_ for _ in range(number_of_entries)]\n",
"companies = pd.DataFrame(columns=[], index=pd.Index(ids, name=\"company_id\"))\n",
"companies\n",
"\n",
"\n",
"id1 = (\n",
" pd.Series(ids * number_of_contacts, name=\"Company 1\")\n",
" .sample(frac=0.7, random_state=42)\n",
" .reset_index(drop=True)\n",
")\n",
"id2 = (\n",
" pd.Series(ids * number_of_contacts, name=\"Company 2\")\n",
" .sample(frac=0.7, random_state=43)\n",
" .reset_index(drop=True)\n",
")\n",
"connections = (\n",
" pd.DataFrame(\n",
" [\n",
" id1,\n",
" pd.Series(\n",
" np.random.randint(0, 100, size=(max(len(id1), len(id2)))),\n",
" name=\"Connection Weight\",\n",
" ),\n",
" id2,\n",
" ]\n",
" )\n",
" .T.dropna()\n",
" .astype(int)\n",
")\n",
"connections = connections.loc[(connections[\"Company 1\"] != connections[\"Company 2\"])]\n",
"connections"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2023-06-03T10:15:42.647508100Z",
"start_time": "2023-06-03T10:15:40.656713900Z"
}
}
},
{
"cell_type": "code",
"execution_count": 69,
"outputs": [
{
"data": {
"text/plain": " Company 1 Connection Weight Company 2\n0 21 36 58\n1 37 59 86\n2 40 26 83\n3 60 21 2\n4 11 2 10\n.. ... ... ...\n695 62 45 11\n696 10 64 27\n697 97 24 55\n698 14 51 66\n699 50 93 82\n\n[693 rows x 3 columns]",
"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>Company 1</th>\n <th>Connection Weight</th>\n <th>Company 2</th>\n </tr>\n </thead>\n <tbody>\n <tr>\n <th>0</th>\n <td>21</td>\n <td>36</td>\n <td>58</td>\n </tr>\n <tr>\n <th>1</th>\n <td>37</td>\n <td>59</td>\n <td>86</td>\n </tr>\n <tr>\n <th>2</th>\n <td>40</td>\n <td>26</td>\n <td>83</td>\n </tr>\n <tr>\n <th>3</th>\n <td>60</td>\n <td>21</td>\n <td>2</td>\n </tr>\n <tr>\n <th>4</th>\n <td>11</td>\n <td>2</td>\n <td>10</td>\n </tr>\n <tr>\n <th>...</th>\n <td>...</td>\n <td>...</td>\n <td>...</td>\n </tr>\n <tr>\n <th>695</th>\n <td>62</td>\n <td>45</td>\n <td>11</td>\n </tr>\n <tr>\n <th>696</th>\n <td>10</td>\n <td>64</td>\n <td>27</td>\n </tr>\n <tr>\n <th>697</th>\n <td>97</td>\n <td>24</td>\n <td>55</td>\n </tr>\n <tr>\n <th>698</th>\n <td>14</td>\n <td>51</td>\n <td>66</td>\n </tr>\n <tr>\n <th>699</th>\n <td>50</td>\n <td>93</td>\n <td>82</td>\n </tr>\n </tbody>\n</table>\n<p>693 rows × 3 columns</p>\n</div>"
},
"execution_count": 69,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"id1 = (\n",
" pd.Series(ids * number_of_contacts, name=\"Company 1\")\n",
" .sample(frac=0.7, random_state=42)\n",
" .reset_index(drop=True)\n",
")\n",
"id2 = (\n",
" pd.Series(ids * number_of_contacts, name=\"Company 2\")\n",
" .sample(frac=0.7, random_state=43)\n",
" .reset_index(drop=True)\n",
")\n",
"connections = (\n",
" pd.DataFrame(\n",
" [\n",
" id1,\n",
" pd.Series(\n",
" np.random.randint(0, 100, size=(max(len(id1), len(id2)))),\n",
" name=\"Connection Weight\",\n",
" ),\n",
" id2,\n",
" ]\n",
" )\n",
" .T.dropna()\n",
" .astype(int)\n",
")\n",
"connections = connections.loc[(connections[\"Company 1\"] != connections[\"Company 2\"])]\n",
"connections"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2023-06-03T01:40:08.441882700Z",
"start_time": "2023-06-03T01:40:08.406876900Z"
}
}
},
{
"cell_type": "code",
"execution_count": 73,
"outputs": [
{
"data": {
"text/plain": " Company 2\nCompany 1 \n0 6\n1 6\n2 5\n3 9\n4 7\n... ...\n95 7\n96 8\n97 7\n98 6\n99 8\n\n[100 rows x 1 columns]",
"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>Company 2</th>\n </tr>\n <tr>\n <th>Company 1</th>\n <th></th>\n </tr>\n </thead>\n <tbody>\n <tr>\n <th>0</th>\n <td>6</td>\n </tr>\n <tr>\n <th>1</th>\n <td>6</td>\n </tr>\n <tr>\n <th>2</th>\n <td>5</td>\n </tr>\n <tr>\n <th>3</th>\n <td>9</td>\n </tr>\n <tr>\n <th>4</th>\n <td>7</td>\n </tr>\n <tr>\n <th>...</th>\n <td>...</td>\n </tr>\n <tr>\n <th>95</th>\n <td>7</td>\n </tr>\n <tr>\n <th>96</th>\n <td>8</td>\n </tr>\n <tr>\n <th>97</th>\n <td>7</td>\n </tr>\n <tr>\n <th>98</th>\n <td>6</td>\n </tr>\n <tr>\n <th>99</th>\n <td>8</td>\n </tr>\n </tbody>\n</table>\n<p>100 rows × 1 columns</p>\n</div>"
},
"execution_count": 73,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"connections[[\"Company 1\", \"Company 2\"]].groupby(\"Company 1\").count()"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2023-06-03T01:44:23.433333600Z",
"start_time": "2023-06-03T01:44:23.424841700Z"
}
}
},
{
"cell_type": "code",
"execution_count": 72,
"outputs": [
{
"data": {
"text/plain": " Analysis-d0 Analysis-d1\ncompany_id \n0 1 6\n1 1 6\n2 1 5\n3 1 9\n4 1 7\n... ... ...\n95 1 7\n96 1 8\n97 1 7\n98 1 6\n99 1 8\n\n[100 rows x 2 columns]",
"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>Analysis-d0</th>\n <th>Analysis-d1</th>\n </tr>\n <tr>\n <th>company_id</th>\n <th></th>\n <th></th>\n </tr>\n </thead>\n <tbody>\n <tr>\n <th>0</th>\n <td>1</td>\n <td>6</td>\n </tr>\n <tr>\n <th>1</th>\n <td>1</td>\n <td>6</td>\n </tr>\n <tr>\n <th>2</th>\n <td>1</td>\n <td>5</td>\n </tr>\n <tr>\n <th>3</th>\n <td>1</td>\n <td>9</td>\n </tr>\n <tr>\n <th>4</th>\n <td>1</td>\n <td>7</td>\n </tr>\n <tr>\n <th>...</th>\n <td>...</td>\n <td>...</td>\n </tr>\n <tr>\n <th>95</th>\n <td>1</td>\n <td>7</td>\n </tr>\n <tr>\n <th>96</th>\n <td>1</td>\n <td>8</td>\n </tr>\n <tr>\n <th>97</th>\n <td>1</td>\n <td>7</td>\n </tr>\n <tr>\n <th>98</th>\n <td>1</td>\n <td>6</td>\n </tr>\n <tr>\n <th>99</th>\n <td>1</td>\n <td>8</td>\n </tr>\n </tbody>\n</table>\n<p>100 rows × 2 columns</p>\n</div>"
},
"execution_count": 72,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"companies[\"Analysis-d0\"] = 1\n",
"companies[\"Analysis-d1\"] = connections[[\"Company 1\", \"Company 2\"]].groupby(\"Company 1\").count()\n",
"connection_sum = connections.join(connections.set_index(\"Company 2\"), on=)\n",
"companies[\"Analysis-d1\"] = connections[[\"Company 1\", \"Company 2\"]].groupby(\"Company 1\").count()\n",
"# for tiers in range(5):\n",
"companies"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2023-06-03T01:43:25.341850700Z",
"start_time": "2023-06-03T01:43:25.318015500Z"
}
}
},
{
"cell_type": "code",
"execution_count": null,
"outputs": [],
"source": [
"companies"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"start_time": "2023-06-03T01:36:32.382091200Z"
}
}
},
{
"cell_type": "code",
"execution_count": null,
"outputs": [],
"source": [],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"start_time": "2023-06-03T01:36:32.385093700Z"
}
}
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.6"
}
},
"nbformat": 4,
"nbformat_minor": 0
}