From 37e53ddb2bee11a1231e82af07855105dd17a3c7 Mon Sep 17 00:00:00 2001 From: Wir Date: Thu, 31 Oct 2024 17:19:52 +0100 Subject: [PATCH] jetzt mit relationsships --- Daten_ohne_relationships.ipynb | 1225 +++++++++++++++++++++++++++++--- 1 file changed, 1109 insertions(+), 116 deletions(-) diff --git a/Daten_ohne_relationships.ipynb b/Daten_ohne_relationships.ipynb index e112c66..1e710d4 100644 --- a/Daten_ohne_relationships.ipynb +++ b/Daten_ohne_relationships.ipynb @@ -327,57 +327,15 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": null, "id": "96784d50-f9bf-43a2-ae95-1e53f9c8ffb4", - "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "
\n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
NameStatusCreated
0W-Raps Saatgut Otello KWS Seed 08/24active14.10.2024
\n", - "
" - ], - "text/plain": [ - " Name Status Created\n", - "0 W-Raps Saatgut Otello KWS Seed 08/24 active 14.10.2024" - ] - }, - "execution_count": 2, - "metadata": {}, - "output_type": "execute_result" - } - ], + "metadata": { + "jupyter": { + "source_hidden": true + }, + "scrolled": true + }, + "outputs": [], "source": [ "#Zeige alle \"seed\" Daten\n", "import pandas as pd\n", @@ -700,65 +658,14 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": null, "id": "d23c84ac-9a04-4019-9b0c-0c549620af35", - "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "
\n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
PlantAreaTimestampLog NameStatusRevision CreatedLink
0W-Raps Helmacker Plant 24/253.1220.10.2024W-Raps Helmacker Harvest 24/25done21.10.2024https://farmos.wagframe.duckdns.org/api/log/ha...
\n", - "
" - ], - "text/plain": [ - " Plant Area Timestamp Log Name Status Revision Created Link\n", - "0 W-Raps Helmacker Plant 24/25 3.12 20.10.2024 W-Raps Helmacker Harvest 24/25 done 21.10.2024 https://farmos.wagframe.duckdns.org/api/log/ha..." - ] - }, - "execution_count": 3, - "metadata": {}, - "output_type": "execute_result" + "metadata": { + "jupyter": { + "source_hidden": true } - ], + }, + "outputs": [], "source": [ "#Versuch\n", "import pandas as pd\n", @@ -826,24 +733,1110 @@ }, { "cell_type": "code", - "execution_count": null, - "id": "434b8acb-89da-4ac0-8a36-0cb70df6db11", - "metadata": {}, - "outputs": [], - "source": [] + "execution_count": 5, + "id": "7c9f3572-702d-4760-a3ec-3f883908ad0f", + "metadata": { + "collapsed": true, + "editable": true, + "jupyter": { + "outputs_hidden": true, + "source_hidden": true + }, + "slideshow": { + "slide_type": "" + }, + "tags": [] + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{\n", + " \"jsonapi\": {\n", + " \"version\": \"1.0\",\n", + " \"meta\": {\n", + " \"links\": {\n", + " \"self\": {\n", + " \"href\": \"http://jsonapi.org/format/1.0/\"\n", + " }\n", + " }\n", + " }\n", + " },\n", + " \"data\": [\n", + " {\n", + " \"type\": \"log--harvest\",\n", + " \"id\": \"750511d3-5f7b-4e70-b541-d2f70696734f\",\n", + " \"links\": {\n", + " \"self\": {\n", + " \"href\": \"https://farmos.wagframe.duckdns.org/api/log/harvest/750511d3-5f7b-4e70-b541-d2f70696734f?resourceVersion=id%3A450\"\n", + " }\n", + " },\n", + " \"attributes\": {\n", + " \"drupal_internal__id\": 94,\n", + " \"drupal_internal__revision_id\": 450,\n", + " \"langcode\": \"en\",\n", + " \"revision_created\": \"2024-10-29T09:24:07+00:00\",\n", + " \"revision_log_message\": null,\n", + " \"name\": \"W-Raps Helmacker Harvest 24/25\",\n", + " \"timestamp\": \"2024-10-20T10:11:15+00:00\",\n", + " \"status\": \"done\",\n", + " \"created\": \"2024-10-15T10:12:32+00:00\",\n", + " \"changed\": \"2024-10-29T09:24:07+00:00\",\n", + " \"default_langcode\": true,\n", + " \"revision_translation_affected\": true,\n", + " \"comment\": {\n", + " \"status\": 2,\n", + " \"cid\": 0,\n", + " \"last_comment_timestamp\": 1728987169,\n", + " \"last_comment_name\": null,\n", + " \"last_comment_uid\": 1,\n", + " \"comment_count\": 0\n", + " },\n", + " \"data\": null,\n", + " \"notes\": null,\n", + " \"flag\": [],\n", + " \"is_group_assignment\": false,\n", + " \"geometry\": null,\n", + " \"is_movement\": false,\n", + " \"quick\": [],\n", + " \"lot_number\": null\n", + " },\n", + " \"relationships\": {\n", + " \"log_type\": {\n", + " \"data\": {\n", + " \"type\": \"log_type--log_type\",\n", + " \"id\": \"bb376a51-4586-46c8-b1cd-cdeea278599a\",\n", + " \"meta\": {\n", + " \"drupal_internal__target_id\": \"harvest\"\n", + " }\n", + " },\n", + " \"links\": {\n", + " \"related\": {\n", + " \"href\": \"https://farmos.wagframe.duckdns.org/api/log/harvest/750511d3-5f7b-4e70-b541-d2f70696734f/log_type?resourceVersion=id%3A450\"\n", + " },\n", + " \"self\": {\n", + " \"href\": \"https://farmos.wagframe.duckdns.org/api/log/harvest/750511d3-5f7b-4e70-b541-d2f70696734f/relationships/log_type?resourceVersion=id%3A450\"\n", + " }\n", + " }\n", + " },\n", + " \"revision_user\": {\n", + " \"data\": {\n", + " \"type\": \"user--user\",\n", + " \"id\": \"a93c675c-72b1-40ea-90ae-41df789b7607\",\n", + " \"meta\": {\n", + " \"drupal_internal__target_id\": 1\n", + " }\n", + " },\n", + " \"links\": {\n", + " \"related\": {\n", + " \"href\": \"https://farmos.wagframe.duckdns.org/api/log/harvest/750511d3-5f7b-4e70-b541-d2f70696734f/revision_user?resourceVersion=id%3A450\"\n", + " },\n", + " \"self\": {\n", + " \"href\": \"https://farmos.wagframe.duckdns.org/api/log/harvest/750511d3-5f7b-4e70-b541-d2f70696734f/relationships/revision_user?resourceVersion=id%3A450\"\n", + " }\n", + " }\n", + " },\n", + " \"uid\": {\n", + " \"data\": {\n", + " \"type\": \"user--user\",\n", + " \"id\": \"a93c675c-72b1-40ea-90ae-41df789b7607\",\n", + " \"meta\": {\n", + " \"drupal_internal__target_id\": 1\n", + " }\n", + " },\n", + " \"links\": {\n", + " \"related\": {\n", + " \"href\": \"https://farmos.wagframe.duckdns.org/api/log/harvest/750511d3-5f7b-4e70-b541-d2f70696734f/uid?resourceVersion=id%3A450\"\n", + " },\n", + " \"self\": {\n", + " \"href\": \"https://farmos.wagframe.duckdns.org/api/log/harvest/750511d3-5f7b-4e70-b541-d2f70696734f/relationships/uid?resourceVersion=id%3A450\"\n", + " }\n", + " }\n", + " },\n", + " \"file\": {\n", + " \"data\": [],\n", + " \"links\": {\n", + " \"related\": {\n", + " \"href\": \"https://farmos.wagframe.duckdns.org/api/log/harvest/750511d3-5f7b-4e70-b541-d2f70696734f/file?resourceVersion=id%3A450\"\n", + " },\n", + " \"self\": {\n", + " \"href\": \"https://farmos.wagframe.duckdns.org/api/log/harvest/750511d3-5f7b-4e70-b541-d2f70696734f/relationships/file?resourceVersion=id%3A450\"\n", + " }\n", + " }\n", + " },\n", + " \"image\": {\n", + " \"data\": [],\n", + " \"links\": {\n", + " \"related\": {\n", + " \"href\": \"https://farmos.wagframe.duckdns.org/api/log/harvest/750511d3-5f7b-4e70-b541-d2f70696734f/image?resourceVersion=id%3A450\"\n", + " },\n", + " \"self\": {\n", + " \"href\": \"https://farmos.wagframe.duckdns.org/api/log/harvest/750511d3-5f7b-4e70-b541-d2f70696734f/relationships/image?resourceVersion=id%3A450\"\n", + " }\n", + " }\n", + " },\n", + " \"group\": {\n", + " \"data\": [],\n", + " \"links\": {\n", + " \"related\": {\n", + " \"href\": \"https://farmos.wagframe.duckdns.org/api/log/harvest/750511d3-5f7b-4e70-b541-d2f70696734f/group?resourceVersion=id%3A450\"\n", + " },\n", + " \"self\": {\n", + " \"href\": \"https://farmos.wagframe.duckdns.org/api/log/harvest/750511d3-5f7b-4e70-b541-d2f70696734f/relationships/group?resourceVersion=id%3A450\"\n", + " }\n", + " }\n", + " },\n", + " \"location\": {\n", + " \"data\": [],\n", + " \"links\": {\n", + " \"related\": {\n", + " \"href\": \"https://farmos.wagframe.duckdns.org/api/log/harvest/750511d3-5f7b-4e70-b541-d2f70696734f/location?resourceVersion=id%3A450\"\n", + " },\n", + " \"self\": {\n", + " \"href\": \"https://farmos.wagframe.duckdns.org/api/log/harvest/750511d3-5f7b-4e70-b541-d2f70696734f/relationships/location?resourceVersion=id%3A450\"\n", + " }\n", + " }\n", + " },\n", + " \"asset\": {\n", + " \"data\": [\n", + " {\n", + " \"type\": \"asset--plant\",\n", + " \"id\": \"76f89f82-1238-43bb-b34f-796a92d491a2\",\n", + " \"meta\": {\n", + " \"drupal_internal__target_id\": 100\n", + " }\n", + " }\n", + " ],\n", + " \"links\": {\n", + " \"related\": {\n", + " \"href\": \"https://farmos.wagframe.duckdns.org/api/log/harvest/750511d3-5f7b-4e70-b541-d2f70696734f/asset?resourceVersion=id%3A450\"\n", + " },\n", + " \"self\": {\n", + " \"href\": \"https://farmos.wagframe.duckdns.org/api/log/harvest/750511d3-5f7b-4e70-b541-d2f70696734f/relationships/asset?resourceVersion=id%3A450\"\n", + " }\n", + " }\n", + " },\n", + " \"category\": {\n", + " \"data\": [],\n", + " \"links\": {\n", + " \"related\": {\n", + " \"href\": \"https://farmos.wagframe.duckdns.org/api/log/harvest/750511d3-5f7b-4e70-b541-d2f70696734f/category?resourceVersion=id%3A450\"\n", + " },\n", + " \"self\": {\n", + " \"href\": \"https://farmos.wagframe.duckdns.org/api/log/harvest/750511d3-5f7b-4e70-b541-d2f70696734f/relationships/category?resourceVersion=id%3A450\"\n", + " }\n", + " }\n", + " },\n", + " \"quantity\": {\n", + " \"data\": [\n", + " {\n", + " \"type\": \"quantity--standard\",\n", + " \"id\": \"c74fca04-27cc-44b1-8139-40f3fe3d3a4e\",\n", + " \"meta\": {\n", + " \"target_revision_id\": 208,\n", + " \"drupal_internal__target_id\": 129\n", + " }\n", + " }\n", + " ],\n", + " \"links\": {\n", + " \"related\": {\n", + " \"href\": \"https://farmos.wagframe.duckdns.org/api/log/harvest/750511d3-5f7b-4e70-b541-d2f70696734f/quantity?resourceVersion=id%3A450\"\n", + " },\n", + " \"self\": {\n", + " \"href\": \"https://farmos.wagframe.duckdns.org/api/log/harvest/750511d3-5f7b-4e70-b541-d2f70696734f/relationships/quantity?resourceVersion=id%3A450\"\n", + " }\n", + " }\n", + " },\n", + " \"owner\": {\n", + " \"data\": [\n", + " {\n", + " \"type\": \"user--user\",\n", + " \"id\": \"a93c675c-72b1-40ea-90ae-41df789b7607\",\n", + " \"meta\": {\n", + " \"drupal_internal__target_id\": 1\n", + " }\n", + " }\n", + " ],\n", + " \"links\": {\n", + " \"related\": {\n", + " \"href\": \"https://farmos.wagframe.duckdns.org/api/log/harvest/750511d3-5f7b-4e70-b541-d2f70696734f/owner?resourceVersion=id%3A450\"\n", + " },\n", + " \"self\": {\n", + " \"href\": \"https://farmos.wagframe.duckdns.org/api/log/harvest/750511d3-5f7b-4e70-b541-d2f70696734f/relationships/owner?resourceVersion=id%3A450\"\n", + " }\n", + " }\n", + " },\n", + " \"equipment\": {\n", + " \"data\": [\n", + " {\n", + " \"type\": \"asset--equipment\",\n", + " \"id\": \"5faba68c-aa10-45b4-b1e0-d687ef1a8562\",\n", + " \"meta\": {\n", + " \"drupal_internal__target_id\": 79\n", + " }\n", + " }\n", + " ],\n", + " \"links\": {\n", + " \"related\": {\n", + " \"href\": \"https://farmos.wagframe.duckdns.org/api/log/harvest/750511d3-5f7b-4e70-b541-d2f70696734f/equipment?resourceVersion=id%3A450\"\n", + " },\n", + " \"self\": {\n", + " \"href\": \"https://farmos.wagframe.duckdns.org/api/log/harvest/750511d3-5f7b-4e70-b541-d2f70696734f/relationships/equipment?resourceVersion=id%3A450\"\n", + " }\n", + " }\n", + " }\n", + " }\n", + " },\n", + " {\n", + " \"type\": \"log--harvest\",\n", + " \"id\": \"71c022be-53c6-481f-b787-da0d16cfbf6f\",\n", + " \"links\": {\n", + " \"self\": {\n", + " \"href\": \"https://farmos.wagframe.duckdns.org/api/log/harvest/71c022be-53c6-481f-b787-da0d16cfbf6f?resourceVersion=id%3A454\"\n", + " }\n", + " },\n", + " \"attributes\": {\n", + " \"drupal_internal__id\": 111,\n", + " \"drupal_internal__revision_id\": 454,\n", + " \"langcode\": \"en\",\n", + " \"revision_created\": \"2024-10-29T12:32:20+00:00\",\n", + " \"revision_log_message\": null,\n", + " \"name\": \"W-Raps Nachtweide Harvest 24/25\",\n", + " \"timestamp\": \"2024-10-28T23:00:00+00:00\",\n", + " \"status\": \"done\",\n", + " \"created\": \"2024-10-15T10:12:32+00:00\",\n", + " \"changed\": \"2024-10-29T12:32:20+00:00\",\n", + " \"default_langcode\": true,\n", + " \"revision_translation_affected\": true,\n", + " \"comment\": {\n", + " \"status\": 2,\n", + " \"cid\": 0,\n", + " \"last_comment_timestamp\": 1730193847,\n", + " \"last_comment_name\": null,\n", + " \"last_comment_uid\": 1,\n", + " \"comment_count\": 0\n", + " },\n", + " \"data\": null,\n", + " \"notes\": null,\n", + " \"flag\": [],\n", + " \"is_group_assignment\": false,\n", + " \"geometry\": null,\n", + " \"is_movement\": false,\n", + " \"quick\": [],\n", + " \"lot_number\": null\n", + " },\n", + " \"relationships\": {\n", + " \"log_type\": {\n", + " \"data\": {\n", + " \"type\": \"log_type--log_type\",\n", + " \"id\": \"bb376a51-4586-46c8-b1cd-cdeea278599a\",\n", + " \"meta\": {\n", + " \"drupal_internal__target_id\": \"harvest\"\n", + " }\n", + " },\n", + " \"links\": {\n", + " \"related\": {\n", + " \"href\": \"https://farmos.wagframe.duckdns.org/api/log/harvest/71c022be-53c6-481f-b787-da0d16cfbf6f/log_type?resourceVersion=id%3A454\"\n", + " },\n", + " \"self\": {\n", + " \"href\": \"https://farmos.wagframe.duckdns.org/api/log/harvest/71c022be-53c6-481f-b787-da0d16cfbf6f/relationships/log_type?resourceVersion=id%3A454\"\n", + " }\n", + " }\n", + " },\n", + " \"revision_user\": {\n", + " \"data\": {\n", + " \"type\": \"user--user\",\n", + " \"id\": \"a93c675c-72b1-40ea-90ae-41df789b7607\",\n", + " \"meta\": {\n", + " \"drupal_internal__target_id\": 1\n", + " }\n", + " },\n", + " \"links\": {\n", + " \"related\": {\n", + " \"href\": \"https://farmos.wagframe.duckdns.org/api/log/harvest/71c022be-53c6-481f-b787-da0d16cfbf6f/revision_user?resourceVersion=id%3A454\"\n", + " },\n", + " \"self\": {\n", + " \"href\": \"https://farmos.wagframe.duckdns.org/api/log/harvest/71c022be-53c6-481f-b787-da0d16cfbf6f/relationships/revision_user?resourceVersion=id%3A454\"\n", + " }\n", + " }\n", + " },\n", + " \"uid\": {\n", + " \"data\": {\n", + " \"type\": \"user--user\",\n", + " \"id\": \"a93c675c-72b1-40ea-90ae-41df789b7607\",\n", + " \"meta\": {\n", + " \"drupal_internal__target_id\": 1\n", + " }\n", + " },\n", + " \"links\": {\n", + " \"related\": {\n", + " \"href\": \"https://farmos.wagframe.duckdns.org/api/log/harvest/71c022be-53c6-481f-b787-da0d16cfbf6f/uid?resourceVersion=id%3A454\"\n", + " },\n", + " \"self\": {\n", + " \"href\": \"https://farmos.wagframe.duckdns.org/api/log/harvest/71c022be-53c6-481f-b787-da0d16cfbf6f/relationships/uid?resourceVersion=id%3A454\"\n", + " }\n", + " }\n", + " },\n", + " \"file\": {\n", + " \"data\": [],\n", + " \"links\": {\n", + " \"related\": {\n", + " \"href\": \"https://farmos.wagframe.duckdns.org/api/log/harvest/71c022be-53c6-481f-b787-da0d16cfbf6f/file?resourceVersion=id%3A454\"\n", + " },\n", + " \"self\": {\n", + " \"href\": \"https://farmos.wagframe.duckdns.org/api/log/harvest/71c022be-53c6-481f-b787-da0d16cfbf6f/relationships/file?resourceVersion=id%3A454\"\n", + " }\n", + " }\n", + " },\n", + " \"image\": {\n", + " \"data\": [],\n", + " \"links\": {\n", + " \"related\": {\n", + " \"href\": \"https://farmos.wagframe.duckdns.org/api/log/harvest/71c022be-53c6-481f-b787-da0d16cfbf6f/image?resourceVersion=id%3A454\"\n", + " },\n", + " \"self\": {\n", + " \"href\": \"https://farmos.wagframe.duckdns.org/api/log/harvest/71c022be-53c6-481f-b787-da0d16cfbf6f/relationships/image?resourceVersion=id%3A454\"\n", + " }\n", + " }\n", + " },\n", + " \"group\": {\n", + " \"data\": [],\n", + " \"links\": {\n", + " \"related\": {\n", + " \"href\": \"https://farmos.wagframe.duckdns.org/api/log/harvest/71c022be-53c6-481f-b787-da0d16cfbf6f/group?resourceVersion=id%3A454\"\n", + " },\n", + " \"self\": {\n", + " \"href\": \"https://farmos.wagframe.duckdns.org/api/log/harvest/71c022be-53c6-481f-b787-da0d16cfbf6f/relationships/group?resourceVersion=id%3A454\"\n", + " }\n", + " }\n", + " },\n", + " \"location\": {\n", + " \"data\": [],\n", + " \"links\": {\n", + " \"related\": {\n", + " \"href\": \"https://farmos.wagframe.duckdns.org/api/log/harvest/71c022be-53c6-481f-b787-da0d16cfbf6f/location?resourceVersion=id%3A454\"\n", + " },\n", + " \"self\": {\n", + " \"href\": \"https://farmos.wagframe.duckdns.org/api/log/harvest/71c022be-53c6-481f-b787-da0d16cfbf6f/relationships/location?resourceVersion=id%3A454\"\n", + " }\n", + " }\n", + " },\n", + " \"asset\": {\n", + " \"data\": [\n", + " {\n", + " \"type\": \"asset--plant\",\n", + " \"id\": \"c0371d6c-0b48-4256-96bc-2c75004e5636\",\n", + " \"meta\": {\n", + " \"drupal_internal__target_id\": 106\n", + " }\n", + " }\n", + " ],\n", + " \"links\": {\n", + " \"related\": {\n", + " \"href\": \"https://farmos.wagframe.duckdns.org/api/log/harvest/71c022be-53c6-481f-b787-da0d16cfbf6f/asset?resourceVersion=id%3A454\"\n", + " },\n", + " \"self\": {\n", + " \"href\": \"https://farmos.wagframe.duckdns.org/api/log/harvest/71c022be-53c6-481f-b787-da0d16cfbf6f/relationships/asset?resourceVersion=id%3A454\"\n", + " }\n", + " }\n", + " },\n", + " \"category\": {\n", + " \"data\": [],\n", + " \"links\": {\n", + " \"related\": {\n", + " \"href\": \"https://farmos.wagframe.duckdns.org/api/log/harvest/71c022be-53c6-481f-b787-da0d16cfbf6f/category?resourceVersion=id%3A454\"\n", + " },\n", + " \"self\": {\n", + " \"href\": \"https://farmos.wagframe.duckdns.org/api/log/harvest/71c022be-53c6-481f-b787-da0d16cfbf6f/relationships/category?resourceVersion=id%3A454\"\n", + " }\n", + " }\n", + " },\n", + " \"quantity\": {\n", + " \"data\": [\n", + " {\n", + " \"type\": \"quantity--standard\",\n", + " \"id\": \"75ddbac7-e03e-41ab-814c-4aab1246ce3e\",\n", + " \"meta\": {\n", + " \"target_revision_id\": 216,\n", + " \"drupal_internal__target_id\": 134\n", + " }\n", + " }\n", + " ],\n", + " \"links\": {\n", + " \"related\": {\n", + " \"href\": \"https://farmos.wagframe.duckdns.org/api/log/harvest/71c022be-53c6-481f-b787-da0d16cfbf6f/quantity?resourceVersion=id%3A454\"\n", + " },\n", + " \"self\": {\n", + " \"href\": \"https://farmos.wagframe.duckdns.org/api/log/harvest/71c022be-53c6-481f-b787-da0d16cfbf6f/relationships/quantity?resourceVersion=id%3A454\"\n", + " }\n", + " }\n", + " },\n", + " \"owner\": {\n", + " \"data\": [\n", + " {\n", + " \"type\": \"user--user\",\n", + " \"id\": \"a93c675c-72b1-40ea-90ae-41df789b7607\",\n", + " \"meta\": {\n", + " \"drupal_internal__target_id\": 1\n", + " }\n", + " }\n", + " ],\n", + " \"links\": {\n", + " \"related\": {\n", + " \"href\": \"https://farmos.wagframe.duckdns.org/api/log/harvest/71c022be-53c6-481f-b787-da0d16cfbf6f/owner?resourceVersion=id%3A454\"\n", + " },\n", + " \"self\": {\n", + " \"href\": \"https://farmos.wagframe.duckdns.org/api/log/harvest/71c022be-53c6-481f-b787-da0d16cfbf6f/relationships/owner?resourceVersion=id%3A454\"\n", + " }\n", + " }\n", + " },\n", + " \"equipment\": {\n", + " \"data\": [\n", + " {\n", + " \"type\": \"asset--equipment\",\n", + " \"id\": \"5faba68c-aa10-45b4-b1e0-d687ef1a8562\",\n", + " \"meta\": {\n", + " \"drupal_internal__target_id\": 79\n", + " }\n", + " }\n", + " ],\n", + " \"links\": {\n", + " \"related\": {\n", + " \"href\": \"https://farmos.wagframe.duckdns.org/api/log/harvest/71c022be-53c6-481f-b787-da0d16cfbf6f/equipment?resourceVersion=id%3A454\"\n", + " },\n", + " \"self\": {\n", + " \"href\": \"https://farmos.wagframe.duckdns.org/api/log/harvest/71c022be-53c6-481f-b787-da0d16cfbf6f/relationships/equipment?resourceVersion=id%3A454\"\n", + " }\n", + " }\n", + " }\n", + " }\n", + " }\n", + " ],\n", + " \"links\": {\n", + " \"self\": {\n", + " \"href\": \"https://farmos.wagframe.duckdns.org/api/log/harvest\"\n", + " }\n", + " }\n", + "}\n" + ] + } + ], + "source": [ + "# Beispiel Json print\n", + "import json\n", + "\n", + "response = farm_client.resource.get('log', 'harvest')\n", + "print(json.dumps(response, indent=4))\n" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "a2300251-b38a-4aa8-abe0-1290572e2d3a", + "metadata": { + "jupyter": { + "source_hidden": true + } + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "W-Raps Helmacker Plant 24/25\n", + "active\n" + ] + } + ], + "source": [ + "# Erhalte Pflanzdaten und speichere den Namen\n", + "plant_id = \"76f89f82-1238-43bb-b34f-796a92d491a2\"\n", + "plant = farm_client.asset.get_id('plant', plant_id)\n", + "plant_name = plant.get('data', {}).get('attributes', {}).get('name', '')\n", + "plant_status= plant.get('data', {}).get('attributes', {}).get('status', '')\n", + "print (plant_name)\n", + "print (plant_status)" + ] }, { "cell_type": "code", "execution_count": null, - "id": "5e6566de-ba49-4566-87c1-37ed165aaff9", - "metadata": {}, + "id": "a48c8376-158d-4877-b86e-fded7aab1b74", + "metadata": { + "jupyter": { + "source_hidden": true + } + }, "outputs": [], - "source": [] + "source": [ + "#Verschachtelte Abfrage test2\n", + "from farmOS import farmOS \n", + "import pandas as pd\n", + "import json\n", + "\n", + "def get_related_logs_of_type(asset, log_type): \n", + " response = farm_client.resource.get('log', log_type)\n", + " ret = []\n", + " for log in response['data']:\n", + " log_assets = log['relationships']['asset']['data']\n", + " for log_asset in log_assets:\n", + " if log_asset['id'] == asset['id']:\n", + " ret.append(log)\n", + " return ret\n", + "\n", + "def get_related_quantities_of_measure(log, measure):\n", + " quantities = log['relationships']['quantity']['data']\n", + " ret = []\n", + " for quant_ref in quantities:\n", + " quant_id = quant_ref['id']\n", + " quant = farm_client.resource.get_id('quantity', 'standard', quant_id)\n", + " if quant['data']['attributes']['measure'] == measure:\n", + " ret.append(quant)\n", + " return ret\n", + "\n", + "def get_related_quantities_of_weight(log, weight):\n", + " quantities = log['relationships']['quantity']['data']\n", + " ret = []\n", + " for quant_ref in quantities:\n", + " quant_id = quant_ref['id']\n", + " quant = farm_client.resource.get_id('quantity', 'standard', quant_id)\n", + " if quant['data']['attributes']['measure'] == weight: # Korrektur: Verwendung von weight\n", + " ret.append(quant)\n", + " return ret\n", + "\n", + "# API-Anfrage, um alle Harvest-Logs zu erhalten\n", + "response = farm_client.resource.get('log', 'harvest')\n", + "\n", + "logs = []\n", + "for item in response.get('data', []):\n", + " # plant name und fläche holen\n", + " assets = item.get('relationships', {}).get('asset', {}).get('data', [])\n", + " plant_name = ''\n", + " plant_area = 0.0\n", + " plant_status = ''\n", + " measure = ''\n", + " weight_measure = ''\n", + "\n", + " for asset in assets:\n", + " if asset['type'] == 'asset--plant': \n", + " plant_id = asset['id']\n", + " \n", + " # Alle Seeding-Logs für das Pflanzasset abrufen\n", + " seedings = get_related_logs_of_type(asset, 'seeding')\n", + " for seeding in seedings:\n", + " area_quants = get_related_quantities_of_measure(seeding, 'area')\n", + " \n", + " for area_quant in area_quants:\n", + " plant_area += float(area_quant.get('data', {}).get('attributes', {}).get('value', {}).get('decimal', 0))\n", + " measure = area_quant.get('data', {}).get('attributes', {}).get('measure', '')\n", + "\n", + " \n", + " \n", + " for seeding in seedings:\n", + " weight_quants = get_related_quantities_of_weight(seeding, 'weight')\n", + " \n", + " for weight_quant in weight_quants:\n", + " weight_measure = weight_quant.get('data', {}).get('attributes', {}).get('measure', '')\n", + " \n", + "\n", + " \n", + " # Pflanzendaten abrufen und Namen sowie Status speichern\n", + " plant = farm_client.asset.get_id('plant', plant_id)\n", + " plant_name = plant.get('data', {}).get('attributes', {}).get('name', '')\n", + " plant_status = plant.get('data', {}).get('attributes', {}).get('status', '')\n", + "\n", + " # Log erstellen und relevante Felder extrahieren\n", + " log = {\n", + " 'Plant': plant_name,\n", + " 'Area': plant_area,\n", + " 'Plant Status': plant_status,\n", + " 'Quantity measure': measure,\n", + " 'Weight measure': weight_measure, # Hinzufügen von weight_measure zur Log-Ausgabe\n", + " 'Timestamp': pd.to_datetime(item['attributes']['timestamp']).strftime('%d.%m.%Y') if 'timestamp' in item['attributes'] else None,\n", + " 'Log Name': item['attributes'].get('name', ''),\n", + " 'Log Status': item['attributes'].get('status', ''),\n", + " 'Revision Created': pd.to_datetime(item['attributes'].get('revision_created')).strftime('%d.%m.%Y') if 'revision_created' in item['attributes'] else None,\n", + " 'Link': item.get('links', {}).get('self', {}).get('href', ''),\n", + " 'Is Movement': item['attributes'].get('is_movement', ''),\n", + " }\n", + " logs.append(log)\n", + "\n", + "# DataFrame aus den Harvest Logs erstellen\n", + "df = pd.DataFrame(logs)\n", + "df\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "id": "b753f464-3a65-4824-a231-6614e156b9e3", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "

W-Raps Helmacker Plant 24/25

" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
 PlantStatusSeedingLog AreaMeasure Quant1SeedingLog Area Quant1SeedingLog AreaMeasure Quant0SeedingLog AreaDecimal Quant0Timestamp HarvestLogLogName HarvestLogLogStatus HarvestLogIsMovement HarvestLog
0activearea3.020000weight50.00000020.10.2024W-Raps Helmacker Harvest 24/25doneFalse
\n" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "

W-Raps Nachtweide Plant 24/25

" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
 PlantStatusSeedingLog AreaMeasure Quant1SeedingLog Area Quant1SeedingLog AreaMeasure Quant0SeedingLog AreaDecimal Quant0Timestamp HarvestLogLogName HarvestLogLogStatus HarvestLogIsMovement HarvestLog
1activearea4.500000weight66.00000028.10.2024W-Raps Nachtweide Harvest 24/25doneFalse
\n" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "#Verschachtelte Abfrage test3\n", + "from farmOS import farmOS \n", + "import pandas as pd\n", + "\n", + "def get_related_logs_of_type(asset, log_type): \n", + " response = farm_client.resource.get('log', log_type)\n", + " return [log for log in response['data'] if any(log_asset['id'] == asset['id'] for log_asset in log['relationships']['asset']['data'])]\n", + "\n", + "def get_related_quantities(log, measure_type):\n", + " quantities = log['relationships']['quantity']['data']\n", + " return [farm_client.resource.get_id('quantity', 'standard', quant_ref['id']) for quant_ref in quantities if farm_client.resource.get_id('quantity', 'standard', quant_ref['id'])['data']['attributes']['measure'] == measure_type]\n", + "\n", + "\n", + "\n", + "\n", + "def get_related_quantities_of_measure(log, measure):\n", + " quantities = log['relationships']['quantity']['data']\n", + " ret = []\n", + " for quant_ref in quantities:\n", + " quant_id = quant_ref['id']\n", + " quant = farm_client.resource.get_id('quantity', 'standard', quant_id)\n", + " if quant['data']['attributes']['measure'] == measure:\n", + " ret.append(quant)\n", + " return ret\n", + "\n", + "# API-Anfrage, um alle Harvest-Logs zu erhalten\n", + "response = farm_client.resource.get('log', 'harvest')\n", + "\n", + "logs = []\n", + "for item in response.get('data', []):\n", + " assets = item.get('relationships', {}).get('asset', {}).get('data', [])\n", + " plant_name = ''\n", + " plant_area = 0.0\n", + " plant_status = ''\n", + " quantity_measure = ''\n", + " weight_measure = ''\n", + " weight_decimal = 0.0\n", + "\n", + " for asset in assets:\n", + " if asset['type'] == 'asset--plant': \n", + " plant_id = asset['id']\n", + " \n", + " # Alle Seeding-Logs für das Pflanzasset abrufen\n", + " seedings = get_related_logs_of_type(asset, 'seeding')\n", + " \n", + " # Fläche und Menge abrufen\n", + " for seeding in seedings:\n", + " area_quants = get_related_quantities(seeding, 'area')\n", + " for area_quant in area_quants:\n", + " plant_area += float(area_quant.get('data', {}).get('attributes', {}).get('value', {}).get('decimal', 0))\n", + " quantity_measure = area_quant.get('data', {}).get('attributes', {}).get('measure', '')\n", + "\n", + " weight_quants = get_related_quantities(seeding, 'weight')\n", + " for weight_quant in weight_quants:\n", + " weight_measure = weight_quant.get('data', {}).get('attributes', {}).get('measure', '')\n", + " weight_decimal += float(weight_quant.get('data', {}).get('attributes', {}).get('value', {}).get('decimal', 0))\n", + " \n", + " # Pflanzendaten abrufen\n", + " plant = farm_client.asset.get_id('plant', plant_id)\n", + " plant_name = plant.get('data', {}).get('attributes', {}).get('name', '')\n", + " plant_status = plant.get('data', {}).get('attributes', {}).get('status', '')\n", + "\n", + " # Log erstellen und relevante Felder extrahieren\n", + " log = {\n", + " 'PlantName': plant_name,\n", + " 'PlantStatus': plant_status,\n", + " 'SeedingLog AreaMeasure Quant1': quantity_measure,\n", + " 'SeedingLog Area Quant1': plant_area,\n", + " 'SeedingLog AreaMeasure Quant0': weight_measure,\n", + " 'SeedingLog AreaDecimal Quant0' : weight_decimal,\n", + " 'Timestamp HarvestLog': pd.to_datetime(item['attributes'].get('timestamp')).strftime('%d.%m.%Y') if 'timestamp' in item['attributes'] else None,\n", + " 'LogName HarvestLog': item['attributes'].get('name', ''),\n", + " 'LogStatus HarvestLog': item['attributes'].get('status', ''),\n", + " 'IsMovement HarvestLog': item['attributes'].get('is_movement', ''),\n", + " }\n", + " logs.append(log)\n", + "\n", + "# DataFrame aus den Harvest Logs erstellen\n", + "df = pd.DataFrame(logs)\n", + "from IPython.display import display, HTML # Für Jupyter Notebook geeignet\n", + "\n", + "# Gruppierung und Anzeige als HTML-Format\n", + "grouped = df.groupby('PlantName')\n", + "for plant, data in grouped:\n", + " display(HTML(f\"

{plant}

\")) # Pflanzname als fettgedruckte Überschrift\n", + " \n", + " # Style der Tabelle anpassen\n", + " styled_table = data.drop(columns=['PlantName']).style.set_table_styles(\n", + " [\n", + " {'selector': 'th', 'props': [('font-weight', 'bold'), ('text-align', 'center'), ('white-space', 'break-spaces'), ('max-width', '100px')]},\n", + " {'selector': 'td', 'props': [('text-align', 'center')]}\n", + " ]\n", + " )\n", + "\n", + " display(styled_table)\n" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "id": "3df54bf3-d8aa-4ec6-bb12-23b05f0aeb99", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "

W-Raps Helmacker Plant 24/25

" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
 PlantStatusSeedingLog AreaMeasure Quant1SeedingLog Area Quant1SeedingLog WeightMeasure Quant0SeedingLog WeightDecimal Quant0Timestamp HarvestLogLogName HarvestLogLogStatus HarvestLogIsMovement HarvestLog
0activearea3.020000weight50.00000020.10.2024W-Raps Helmacker Harvest 24/25doneFalse
\n" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "

W-Raps Nachtweide Plant 24/25

" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
 PlantStatusSeedingLog AreaMeasure Quant1SeedingLog Area Quant1SeedingLog WeightMeasure Quant0SeedingLog WeightDecimal Quant0Timestamp HarvestLogLogName HarvestLogLogStatus HarvestLogIsMovement HarvestLog
1activearea4.500000weight66.00000028.10.2024W-Raps Nachtweide Harvest 24/25doneFalse
\n" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "testtttt\n", + "from farmOS import farmOS \n", + "import pandas as pd\n", + "\n", + "def get_related_logs_of_type(asset, log_type): \n", + " response = farm_client.resource.get('log', log_type)\n", + " return [log for log in response['data'] if any(log_asset['id'] == asset['id'] for log_asset in log['relationships']['asset']['data'])]\n", + "\n", + "def get_related_quantities(log, measure_type):\n", + " quantities = log['relationships']['quantity']['data']\n", + " return [farm_client.resource.get_id('quantity', 'standard', quant_ref['id']) \n", + " for quant_ref in quantities \n", + " if farm_client.resource.get_id('quantity', 'standard', quant_ref['id'])['data']['attributes']['measure'] == measure_type]\n", + "\n", + "def get_related_taxonomy_units(taxonomy_term, measure):\n", + " taxonomy = taxonomy_term['relationships']['units']['data']\n", + " ret = []\n", + " for tax_ref in taxonomy:\n", + " tax_id = tax_ref['id']\n", + " quant = farm_client.resource.get_id('quantity', 'standard', tax_id)\n", + " if quant['data']['attributes']['measure'] == measure:\n", + " ret.append(quant)\n", + " return ret\n", + "\n", + "# API-Anfrage, um alle Harvest-Logs zu erhalten\n", + "response = farm_client.resource.get('log', 'harvest')\n", + "\n", + "logs = []\n", + "for item in response.get('data', []):\n", + " assets = item.get('relationships', {}).get('asset', {}).get('data', [])\n", + " plant_name = ''\n", + " plant_area = 0.0\n", + " plant_status = ''\n", + " quantity_measure = ''\n", + " weight_measure = ''\n", + " weight_decimal = 0.0\n", + "\n", + " for asset in assets:\n", + " if asset['type'] == 'asset--plant': \n", + " plant_id = asset['id']\n", + " \n", + " # Alle Seeding-Logs für das Pflanzasset abrufen\n", + " seedings = get_related_logs_of_type(asset, 'seeding')\n", + " \n", + " # Fläche und Menge abrufen\n", + " for seeding in seedings:\n", + " area_quants = get_related_quantities(seeding, 'area')\n", + " for area_quant in area_quants:\n", + " plant_area += float(area_quant.get('data', {}).get('attributes', {}).get('value', {}).get('decimal', 0))\n", + " quantity_measure = area_quant.get('data', {}).get('attributes', {}).get('measure', '')\n", + "\n", + " weight_quants = get_related_quantities(seeding, 'weight')\n", + " for weight_quant in weight_quants:\n", + " weight_measure = weight_quant.get('data', {}).get('attributes', {}).get('measure', '')\n", + " weight_decimal += float(weight_quant.get('data', {}).get('attributes', {}).get('value', {}).get('decimal', 0))\n", + " \n", + " # Pflanzendaten abrufen\n", + " plant = farm_client.asset.get_id('plant', plant_id)\n", + " plant_name = plant.get('data', {}).get('attributes', {}).get('name', '')\n", + " plant_status = plant.get('data', {}).get('attributes', {}).get('status', '')\n", + "\n", + " # Log erstellen und relevante Felder extrahieren\n", + " log = {\n", + " 'PlantName': plant_name,\n", + " 'PlantStatus': plant_status,\n", + " 'SeedingLog AreaMeasure Quant1': quantity_measure,\n", + " 'SeedingLog Area Quant1': plant_area,\n", + " 'SeedingLog WeightMeasure Quant0': weight_measure,\n", + " 'SeedingLog WeightDecimal Quant0' : weight_decimal,\n", + " 'Timestamp HarvestLog': pd.to_datetime(item['attributes'].get('timestamp')).strftime('%d.%m.%Y') if 'timestamp' in item['attributes'] else None,\n", + " 'LogName HarvestLog': item['attributes'].get('name', ''),\n", + " 'LogStatus HarvestLog': item['attributes'].get('status', ''),\n", + " 'IsMovement HarvestLog': item['attributes'].get('is_movement', ''),\n", + " }\n", + " logs.append(log)\n", + "\n", + "# DataFrame aus den Harvest Logs erstellen\n", + "df = pd.DataFrame(logs)\n", + "from IPython.display import display, HTML # Für Jupyter Notebook geeignet\n", + "\n", + "# Gruppierung und Anzeige als HTML-Format\n", + "grouped = df.groupby('PlantName')\n", + "for plant, data in grouped:\n", + " display(HTML(f\"

{plant}

\")) # Pflanzname als fettgedruckte Überschrift\n", + " \n", + " # Style der Tabelle anpassen\n", + " styled_table = data.drop(columns=['PlantName']).style.set_table_styles(\n", + " [\n", + " {'selector': 'th', 'props': [('font-weight', 'bold'), ('text-align', 'center'), ('white-space', 'break-spaces'), ('max-width', '100px')]},\n", + " {'selector': 'td', 'props': [('text-align', 'center')]}\n", + " ]\n", + " )\n", + "\n", + " display(styled_table)\n" + ] }, { "cell_type": "code", "execution_count": null, - "id": "2c4d4aa6-0a3b-4860-b186-965e827f8eed", + "id": "da71b53e-0621-47af-84ca-11e266ec8c2e", "metadata": {}, "outputs": [], "source": []