{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "# GeoPython Lab 02 — pandas & Data\n",
        "**Στόχος:** δημιουργία πίνακα, βασικά στατιστικά, φίλτρα και γράφημα.\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "import pandas as pd\n",
        "\n",
        "df = pd.DataFrame({\n",
        "    \"parcel_id\": [101, 102, 103, 104, 105],\n",
        "    \"area_m2\": [1250, 980, 3210, 1540, 2760],\n",
        "    \"crop\": [\"wheat\", \"maize\", \"wheat\", \"cotton\", \"maize\"]\n",
        "})\n",
        "df\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "df.describe(include=\"all\")\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "# Αγροτεμάχια άνω των 1500 m²\n",
        "large = df[df[\"area_m2\"] > 1500]\n",
        "large\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "# Συνολικό εμβαδόν ανά καλλιέργεια\n",
        "df.groupby(\"crop\", as_index=False)[\"area_m2\"].sum()\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "import matplotlib.pyplot as plt\n",
        "\n",
        "df.groupby(\"crop\")[\"area_m2\"].sum().plot(kind=\"bar\")\n",
        "plt.ylabel(\"Συνολικό εμβαδόν (m²)\")\n",
        "plt.title(\"Εμβαδόν ανά καλλιέργεια\")\n",
        "plt.show()\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Μικρή άσκηση\n",
        "Πρόσθεσε στήλη `yield_kg` και υπολόγισε τη μέση παραγωγή ανά καλλιέργεια.\n"
      ]
    }
  ],
  "metadata": {
    "kernelspec": {
      "display_name": "Python 3",
      "language": "python",
      "name": "python3"
    },
    "language_info": {
      "name": "python",
      "version": "3.x"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 5
}