Created
February 20, 2020 11:55
-
-
Save messa/624a24041f1fbf664fa2f5965c96bd19 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "nbformat": 4, | |
| "nbformat_minor": 0, | |
| "metadata": { | |
| "colab": { | |
| "name": "2020-02-20 radky.ipynb", | |
| "provenance": [] | |
| }, | |
| "kernelspec": { | |
| "name": "python3", | |
| "display_name": "Python 3" | |
| } | |
| }, | |
| "cells": [ | |
| { | |
| "cell_type": "code", | |
| "metadata": { | |
| "id": "Y0GR-wCKaJN5", | |
| "colab_type": "code", | |
| "colab": {} | |
| }, | |
| "source": [ | |
| "import pandas as pd\n", | |
| "from pandas import DataFrame" | |
| ], | |
| "execution_count": 0, | |
| "outputs": [] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "metadata": { | |
| "id": "QfUWbjjLaeTf", | |
| "colab_type": "code", | |
| "colab": {} | |
| }, | |
| "source": [ | |
| "tabulka_a = DataFrame(data=[\n", | |
| " dict(a=22, b='dd', c='ee', d='ff'),\n", | |
| " dict(a=11, b='aa', c='bb', d='cc'),\n", | |
| " dict(a=33, b='gg', c='hh', d='ii'),\n", | |
| "])\n", | |
| "tabulka_b = DataFrame(data=[\n", | |
| " dict(a=11, b='aa', c='hh', d='cc'),\n", | |
| " dict(a=11, b='aa', c='bb', d='cc'),\n", | |
| " dict(a=55, b='hh', c='nn', d='mm'),\n", | |
| " dict(a=22, b='dd', c='ee', d='ff'),\n", | |
| "])" | |
| ], | |
| "execution_count": 0, | |
| "outputs": [] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "metadata": { | |
| "id": "l18JMPWkaqhP", | |
| "colab_type": "code", | |
| "colab": { | |
| "base_uri": "https://localhost:8080/", | |
| "height": 142 | |
| }, | |
| "outputId": "105f3554-cfad-4f3c-af9c-158a91046b5a" | |
| }, | |
| "source": [ | |
| "tabulka_a" | |
| ], | |
| "execution_count": 8, | |
| "outputs": [ | |
| { | |
| "output_type": "execute_result", | |
| "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>a</th>\n", | |
| " <th>b</th>\n", | |
| " <th>c</th>\n", | |
| " <th>d</th>\n", | |
| " </tr>\n", | |
| " </thead>\n", | |
| " <tbody>\n", | |
| " <tr>\n", | |
| " <th>0</th>\n", | |
| " <td>22</td>\n", | |
| " <td>dd</td>\n", | |
| " <td>ee</td>\n", | |
| " <td>ff</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>1</th>\n", | |
| " <td>11</td>\n", | |
| " <td>aa</td>\n", | |
| " <td>bb</td>\n", | |
| " <td>cc</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>2</th>\n", | |
| " <td>33</td>\n", | |
| " <td>gg</td>\n", | |
| " <td>hh</td>\n", | |
| " <td>ii</td>\n", | |
| " </tr>\n", | |
| " </tbody>\n", | |
| "</table>\n", | |
| "</div>" | |
| ], | |
| "text/plain": [ | |
| " a b c d\n", | |
| "0 22 dd ee ff\n", | |
| "1 11 aa bb cc\n", | |
| "2 33 gg hh ii" | |
| ] | |
| }, | |
| "metadata": { | |
| "tags": [] | |
| }, | |
| "execution_count": 8 | |
| } | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "metadata": { | |
| "id": "wf3AwrVkasXG", | |
| "colab_type": "code", | |
| "colab": { | |
| "base_uri": "https://localhost:8080/", | |
| "height": 173 | |
| }, | |
| "outputId": "53208926-6f80-4d9b-e7e2-2d80dde70642" | |
| }, | |
| "source": [ | |
| "tabulka_b" | |
| ], | |
| "execution_count": 9, | |
| "outputs": [ | |
| { | |
| "output_type": "execute_result", | |
| "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>a</th>\n", | |
| " <th>b</th>\n", | |
| " <th>c</th>\n", | |
| " <th>d</th>\n", | |
| " </tr>\n", | |
| " </thead>\n", | |
| " <tbody>\n", | |
| " <tr>\n", | |
| " <th>0</th>\n", | |
| " <td>11</td>\n", | |
| " <td>aa</td>\n", | |
| " <td>hh</td>\n", | |
| " <td>cc</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>1</th>\n", | |
| " <td>11</td>\n", | |
| " <td>aa</td>\n", | |
| " <td>bb</td>\n", | |
| " <td>cc</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>2</th>\n", | |
| " <td>55</td>\n", | |
| " <td>hh</td>\n", | |
| " <td>nn</td>\n", | |
| " <td>mm</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>3</th>\n", | |
| " <td>22</td>\n", | |
| " <td>dd</td>\n", | |
| " <td>ee</td>\n", | |
| " <td>ff</td>\n", | |
| " </tr>\n", | |
| " </tbody>\n", | |
| "</table>\n", | |
| "</div>" | |
| ], | |
| "text/plain": [ | |
| " a b c d\n", | |
| "0 11 aa hh cc\n", | |
| "1 11 aa bb cc\n", | |
| "2 55 hh nn mm\n", | |
| "3 22 dd ee ff" | |
| ] | |
| }, | |
| "metadata": { | |
| "tags": [] | |
| }, | |
| "execution_count": 9 | |
| } | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "metadata": { | |
| "id": "UBUjUfWsbN4L", | |
| "colab_type": "code", | |
| "colab": { | |
| "base_uri": "https://localhost:8080/", | |
| "height": 142 | |
| }, | |
| "outputId": "868ee409-fb50-4cf5-9557-cf839cd579f0" | |
| }, | |
| "source": [ | |
| "pd.merge(tabulka_a, tabulka_b, how='left', indicator=True)" | |
| ], | |
| "execution_count": 17, | |
| "outputs": [ | |
| { | |
| "output_type": "execute_result", | |
| "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>a</th>\n", | |
| " <th>b</th>\n", | |
| " <th>c</th>\n", | |
| " <th>d</th>\n", | |
| " <th>_merge</th>\n", | |
| " </tr>\n", | |
| " </thead>\n", | |
| " <tbody>\n", | |
| " <tr>\n", | |
| " <th>0</th>\n", | |
| " <td>22</td>\n", | |
| " <td>dd</td>\n", | |
| " <td>ee</td>\n", | |
| " <td>ff</td>\n", | |
| " <td>both</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>1</th>\n", | |
| " <td>11</td>\n", | |
| " <td>aa</td>\n", | |
| " <td>bb</td>\n", | |
| " <td>cc</td>\n", | |
| " <td>both</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>2</th>\n", | |
| " <td>33</td>\n", | |
| " <td>gg</td>\n", | |
| " <td>hh</td>\n", | |
| " <td>ii</td>\n", | |
| " <td>left_only</td>\n", | |
| " </tr>\n", | |
| " </tbody>\n", | |
| "</table>\n", | |
| "</div>" | |
| ], | |
| "text/plain": [ | |
| " a b c d _merge\n", | |
| "0 22 dd ee ff both\n", | |
| "1 11 aa bb cc both\n", | |
| "2 33 gg hh ii left_only" | |
| ] | |
| }, | |
| "metadata": { | |
| "tags": [] | |
| }, | |
| "execution_count": 17 | |
| } | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "metadata": { | |
| "id": "LVuJyvgZcA3q", | |
| "colab_type": "code", | |
| "colab": {} | |
| }, | |
| "source": [ | |
| "" | |
| ], | |
| "execution_count": 0, | |
| "outputs": [] | |
| } | |
| ] | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment