{ "cells": [ { "cell_type": "markdown", "id": "2bb8a171", "metadata": {}, "source": [ "# `unique` und andere Mengenlogik\n", "\n", "NumPy hat einige grundlegende Mengenoperationen für eindimensionale `ndarray`. Eine häufig verwendete ist [numpy.unique](https://numpy.org/doc/stable/reference/generated/numpy.unique.html), die die sortierten eindeutigen Werte in einem Array zurückgibt:" ] }, { "cell_type": "code", "execution_count": 1, "id": "7cc7e817", "metadata": { "execution": { "iopub.execute_input": "2026-05-21T17:16:37.766467Z", "iopub.status.busy": "2026-05-21T17:16:37.766318Z", "iopub.status.idle": "2026-05-21T17:16:37.802016Z", "shell.execute_reply": "2026-05-21T17:16:37.801700Z", "shell.execute_reply.started": "2026-05-21T17:16:37.766451Z" } }, "outputs": [], "source": [ "import numpy as np\n", "\n", "\n", "names = np.array(\n", " [\n", " \"Andrea\",\n", " \"Tim\",\n", " \"Veit\",\n", " \"Tim\",\n", " ],\n", ")" ] }, { "cell_type": "code", "execution_count": 2, "id": "254fa327", "metadata": { "execution": { "iopub.execute_input": "2026-05-21T17:16:37.802508Z", "iopub.status.busy": "2026-05-21T17:16:37.802392Z", "iopub.status.idle": "2026-05-21T17:16:37.806004Z", "shell.execute_reply": "2026-05-21T17:16:37.805702Z", "shell.execute_reply.started": "2026-05-21T17:16:37.802495Z" } }, "outputs": [ { "data": { "text/plain": [ "array(['Andrea', 'Tim', 'Veit'], dtype='