{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# The Land of Poets Challenge" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "For a digital humanities project you need to display Italian poets by filtering a csv table according to various criteria. This challenge will be only about querying with Polars, which is something you might find convenient to do during exams for quickly understanding datasets content (using Polars will always be optional, you will never be asked to perform complex modifications with it)\n", "\n", "You are given a dataset taken from [Wikidata](https://www.wikidata.org/wiki/Wikidata:Main_Page), a project by the Wikimedia foundation which aims to store only machine-readable data, like numbers, strings, and so on interlinked with many references. Each entity in Wikidata has an identifier, for example Dante Alighieri is the entity [Q1067](https://www.wikidata.org/wiki/Q1067) and Florence is [Q2044](https://www.wikidata.org/wiki/Q2044)\n", "\n", "Wikidata can be queried using the SPARQL language: the data was obtained with [this query](https://query.wikidata.org/#%23defaultView%3AMap%7B%22hide%22%3A%20%5B%22%3Fcoord%22%5D%7D%0ASELECT%20%3Fsubj%20%3FsubjLabel%20%3Fplace%20%3FplaceLabel%20%3Fcoord%20%3Fbirthyear%0AWHERE%20%7B%0A%20%20%20%3Fsubj%20wdt%3AP106%20wd%3AQ49757%20.%0A%20%20%20%3Fsubj%20wdt%3AP19%20%3Fplace%20.%0A%20%20%20%3Fplace%20wdt%3AP17%20wd%3AQ38%20.%0A%20%20%20%3Fplace%20wdt%3AP625%20%3Fcoord%20.%0A%20%20%20OPTIONAL%20%7B%20%3Fsubj%20wdt%3AP569%20%3Fdob%20%7D%0A%20%20%20BIND%28YEAR%28%3Fdob%29%20as%20%3Fbirthyear%29%0ASERVICE%20wikibase%3Alabel%20%7B%20%20bd%3AserviceParam%20wikibase%3Alanguage%20%22%5BAUTO_LANGUAGE%5D%2Cen%22%20%7D%0A%7D) and downloaded in CSV format (among the many which can be chosen). Even if not necessary for the purposes of the exercise, you are invited to play a bit with the interface, like trying different visualizations (i.e. try select map in the middle-left corner) - or see [other examples](https://www.wikidata.org/wiki/Wikidata:SPARQL_query_service/queries/examples)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import polars as pl" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Load the dataset\n", "\n", "First load the dataset [italian-poets.csv](data/italian-poets.csv) in Polars dataframe `df` " ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "shape: (3_198, 9)
subjsubjLabelplaceplaceLabelcoordbirthyearlatitudeplace_idsubj_id
strstrstrstrstri64f64strstr
"http://www.wikidata.org/entity…"Aemilius Macer""http://www.wikidata.org/entity…"Verona""Point(10.992777777 45.43861111…null45.438611"Q2028""Q8797"
"http://www.wikidata.org/entity…"Gaius Maecenas""http://www.wikidata.org/entity…"Arezzo""Point(11.878055555 43.46305555…null43.463056"Q13378""Q8833"
"http://www.wikidata.org/entity…"Michelangelo""http://www.wikidata.org/entity…"Caprese Michelangelo""Point(11.985833333 43.64083333…147543.640833"Q52069""Q5592"
"http://www.wikidata.org/entity…"Horace""http://www.wikidata.org/entity…"Venosa""Point(15.816666666 40.96666666…-6440.966667"Q52691""Q6197"
"http://www.wikidata.org/entity…"Sallust""http://www.wikidata.org/entity…"Amiternum""Point(13.305769 42.400776)"-8542.400776"Q177061""Q7170"
"http://www.wikidata.org/entity…"Giovanni Marrasio""http://www.wikidata.org/entity…"Noto""Point(15.083333333 36.88333333…140536.883333"Q487174""Q99308713"
"http://www.wikidata.org/entity…"Annemarie Innerebner""http://www.wikidata.org/entity…"Bolzano""Point(11.35 46.5)"192446.5"Q6526""Q100775377"
"http://www.wikidata.org/entity…"Nesti Lyro Wollek""http://www.wikidata.org/entity…"Florence""Point(11.254166666 43.77138888…187543.771389"Q2044""Q100775410"
"http://www.wikidata.org/entity…"Lorenza Meletti""http://www.wikidata.org/entity…"Bondeno""Point(11.41542 44.88944)"194044.88944"Q95093""Q99655533"
"http://www.wikidata.org/entity…"Nanni Falconi""http://www.wikidata.org/entity…"Pattada""Point(9.11 40.582222222)"195040.582222"Q391218""Q99912619"
" ], "text/plain": [ "shape: (3_198, 9)\n", "┌───────────┬───────────┬───────────┬───────────┬───┬───────────┬───────────┬──────────┬───────────┐\n", "│ subj ┆ subjLabel ┆ place ┆ placeLabe ┆ … ┆ birthyear ┆ latitude ┆ place_id ┆ subj_id │\n", "│ --- ┆ --- ┆ --- ┆ l ┆ ┆ --- ┆ --- ┆ --- ┆ --- │\n", "│ str ┆ str ┆ str ┆ --- ┆ ┆ i64 ┆ f64 ┆ str ┆ str │\n", "│ ┆ ┆ ┆ str ┆ ┆ ┆ ┆ ┆ │\n", "╞═══════════╪═══════════╪═══════════╪═══════════╪═══╪═══════════╪═══════════╪══════════╪═══════════╡\n", "│ http://ww ┆ Aemilius ┆ http://ww ┆ Verona ┆ … ┆ null ┆ 45.438611 ┆ Q2028 ┆ Q8797 │\n", "│ w.wikidat ┆ Macer ┆ w.wikidat ┆ ┆ ┆ ┆ ┆ ┆ │\n", "│ a.org/ent ┆ ┆ a.org/ent ┆ ┆ ┆ ┆ ┆ ┆ │\n", "│ ity… ┆ ┆ ity… ┆ ┆ ┆ ┆ ┆ ┆ │\n", "│ http://ww ┆ Gaius ┆ http://ww ┆ Arezzo ┆ … ┆ null ┆ 43.463056 ┆ Q13378 ┆ Q8833 │\n", "│ w.wikidat ┆ Maecenas ┆ w.wikidat ┆ ┆ ┆ ┆ ┆ ┆ │\n", "│ a.org/ent ┆ ┆ a.org/ent ┆ ┆ ┆ ┆ ┆ ┆ │\n", "│ ity… ┆ ┆ ity… ┆ ┆ ┆ ┆ ┆ ┆ │\n", "│ http://ww ┆ Michelang ┆ http://ww ┆ Caprese ┆ … ┆ 1475 ┆ 43.640833 ┆ Q52069 ┆ Q5592 │\n", "│ w.wikidat ┆ elo ┆ w.wikidat ┆ Michelang ┆ ┆ ┆ ┆ ┆ │\n", "│ a.org/ent ┆ ┆ a.org/ent ┆ elo ┆ ┆ ┆ ┆ ┆ │\n", "│ ity… ┆ ┆ ity… ┆ ┆ ┆ ┆ ┆ ┆ │\n", "│ http://ww ┆ Horace ┆ http://ww ┆ Venosa ┆ … ┆ -64 ┆ 40.966667 ┆ Q52691 ┆ Q6197 │\n", "│ w.wikidat ┆ ┆ w.wikidat ┆ ┆ ┆ ┆ ┆ ┆ │\n", "│ a.org/ent ┆ ┆ a.org/ent ┆ ┆ ┆ ┆ ┆ ┆ │\n", "│ ity… ┆ ┆ ity… ┆ ┆ ┆ ┆ ┆ ┆ │\n", "│ http://ww ┆ Sallust ┆ http://ww ┆ Amiternum ┆ … ┆ -85 ┆ 42.400776 ┆ Q177061 ┆ Q7170 │\n", "│ w.wikidat ┆ ┆ w.wikidat ┆ ┆ ┆ ┆ ┆ ┆ │\n", "│ a.org/ent ┆ ┆ a.org/ent ┆ ┆ ┆ ┆ ┆ ┆ │\n", "│ ity… ┆ ┆ ity… ┆ ┆ ┆ ┆ ┆ ┆ │\n", "│ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … │\n", "│ http://ww ┆ Giovanni ┆ http://ww ┆ Noto ┆ … ┆ 1405 ┆ 36.883333 ┆ Q487174 ┆ Q99308713 │\n", "│ w.wikidat ┆ Marrasio ┆ w.wikidat ┆ ┆ ┆ ┆ ┆ ┆ │\n", "│ a.org/ent ┆ ┆ a.org/ent ┆ ┆ ┆ ┆ ┆ ┆ │\n", "│ ity… ┆ ┆ ity… ┆ ┆ ┆ ┆ ┆ ┆ │\n", "│ http://ww ┆ Annemarie ┆ http://ww ┆ Bolzano ┆ … ┆ 1924 ┆ 46.5 ┆ Q6526 ┆ Q10077537 │\n", "│ w.wikidat ┆ Innerebne ┆ w.wikidat ┆ ┆ ┆ ┆ ┆ ┆ 7 │\n", "│ a.org/ent ┆ r ┆ a.org/ent ┆ ┆ ┆ ┆ ┆ ┆ │\n", "│ ity… ┆ ┆ ity… ┆ ┆ ┆ ┆ ┆ ┆ │\n", "│ http://ww ┆ Nesti ┆ http://ww ┆ Florence ┆ … ┆ 1875 ┆ 43.771389 ┆ Q2044 ┆ Q10077541 │\n", "│ w.wikidat ┆ Lyro ┆ w.wikidat ┆ ┆ ┆ ┆ ┆ ┆ 0 │\n", "│ a.org/ent ┆ Wollek ┆ a.org/ent ┆ ┆ ┆ ┆ ┆ ┆ │\n", "│ ity… ┆ ┆ ity… ┆ ┆ ┆ ┆ ┆ ┆ │\n", "│ http://ww ┆ Lorenza ┆ http://ww ┆ Bondeno ┆ … ┆ 1940 ┆ 44.88944 ┆ Q95093 ┆ Q99655533 │\n", "│ w.wikidat ┆ Meletti ┆ w.wikidat ┆ ┆ ┆ ┆ ┆ ┆ │\n", "│ a.org/ent ┆ ┆ a.org/ent ┆ ┆ ┆ ┆ ┆ ┆ │\n", "│ ity… ┆ ┆ ity… ┆ ┆ ┆ ┆ ┆ ┆ │\n", "│ http://ww ┆ Nanni ┆ http://ww ┆ Pattada ┆ … ┆ 1950 ┆ 40.582222 ┆ Q391218 ┆ Q99912619 │\n", "│ w.wikidat ┆ Falconi ┆ w.wikidat ┆ ┆ ┆ ┆ ┆ ┆ │\n", "│ a.org/ent ┆ ┆ a.org/ent ┆ ┆ ┆ ┆ ┆ ┆ │\n", "│ ity… ┆ ┆ ity… ┆ ┆ ┆ ┆ ┆ ┆ │\n", "└───────────┴───────────┴───────────┴───────────┴───┴───────────┴───────────┴──────────┴───────────┘" ] }, "execution_count": null, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Tell me more\n", "\n", "Show some info about the dataset" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "shape: (9, 7)
statisticsubjsubjLabelplaceplaceLabelcoordbirthyear
strstrstrstrstrstrf64
"count""3198""3198""3198""3198""3198"3070.0
"null_count""0""0""0""0""0"128.0
"mean"nullnullnullnullnull1724.418893
"std"nullnullnullnullnull373.394174
"min""http://www.wikidata.org/entity…"Abd ar-Rahman al-Itrabanishi""http://www.wikidata.org/entity…"Aci Catena""Point(10.033333333 44.26666666…-629.0
"25%"nullnullnullnullnull1647.0
"50%"nullnullnullnullnull1855.0
"75%"nullnullnullnullnull1922.0
"max""http://www.wikidata.org/entity…"Đuro Matijašević""http://www.wikidata.org/entity…"ancient Syracuse""Point(9.983333333 45.316666666…2000.0
" ], "text/plain": [ "shape: (9, 7)\n", "┌────────────┬──────────────┬──────────────┬─────────────┬─────────────┬─────────────┬─────────────┐\n", "│ statistic ┆ subj ┆ subjLabel ┆ place ┆ placeLabel ┆ coord ┆ birthyear │\n", "│ --- ┆ --- ┆ --- ┆ --- ┆ --- ┆ --- ┆ --- │\n", "│ str ┆ str ┆ str ┆ str ┆ str ┆ str ┆ f64 │\n", "╞════════════╪══════════════╪══════════════╪═════════════╪═════════════╪═════════════╪═════════════╡\n", "│ count ┆ 3198 ┆ 3198 ┆ 3198 ┆ 3198 ┆ 3198 ┆ 3070.0 │\n", "│ null_count ┆ 0 ┆ 0 ┆ 0 ┆ 0 ┆ 0 ┆ 128.0 │\n", "│ mean ┆ null ┆ null ┆ null ┆ null ┆ null ┆ 1724.418893 │\n", "│ std ┆ null ┆ null ┆ null ┆ null ┆ null ┆ 373.394174 │\n", "│ min ┆ http://www.w ┆ Abd ┆ http://www. ┆ Aci Catena ┆ Point(10.03 ┆ -629.0 │\n", "│ ┆ ikidata.org/ ┆ ar-Rahman ┆ wikidata.or ┆ ┆ 3333333 44. ┆ │\n", "│ ┆ entity… ┆ al-Itrabanis ┆ g/entity… ┆ ┆ 26666666… ┆ │\n", "│ ┆ ┆ hi ┆ ┆ ┆ ┆ │\n", "│ 25% ┆ null ┆ null ┆ null ┆ null ┆ null ┆ 1647.0 │\n", "│ 50% ┆ null ┆ null ┆ null ┆ null ┆ null ┆ 1855.0 │\n", "│ 75% ┆ null ┆ null ┆ null ┆ null ┆ null ┆ 1922.0 │\n", "│ max ┆ http://www.w ┆ Đuro ┆ http://www. ┆ ancient ┆ Point(9.983 ┆ 2000.0 │\n", "│ ┆ ikidata.org/ ┆ Matijašević ┆ wikidata.or ┆ Syracuse ┆ 333333 45.3 ┆ │\n", "│ ┆ entity… ┆ ┆ g/entity… ┆ ┆ 16666666… ┆ │\n", "└────────────┴──────────────┴──────────────┴─────────────┴─────────────┴─────────────┴─────────────┘" ] }, "execution_count": null, "metadata": {}, "output_type": "execute_result" } ], "source": [ "info" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Getting in shape\n", "\n", "Show the rows and the columns counts:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "rows: 3198\n", "columns: 6\n" ] } ], "source": [ "print(f\"rows: {nr_rows}\")\n", "print(f\"columns: {nr_cols}\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 10 rows \n", "\n", "Display first 10 rows" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "shape: (10, 9)
subjsubjLabelplaceplaceLabelcoordbirthyearlatitudeplace_idsubj_id
strstrstrstrstri64f64strstr
"http://www.wikidata.org/entity…"Aemilius Macer""http://www.wikidata.org/entity…"Verona""Point(10.992777777 45.43861111…null45.438611"Q2028""Q8797"
"http://www.wikidata.org/entity…"Gaius Maecenas""http://www.wikidata.org/entity…"Arezzo""Point(11.878055555 43.46305555…null43.463056"Q13378""Q8833"
"http://www.wikidata.org/entity…"Michelangelo""http://www.wikidata.org/entity…"Caprese Michelangelo""Point(11.985833333 43.64083333…147543.640833"Q52069""Q5592"
"http://www.wikidata.org/entity…"Horace""http://www.wikidata.org/entity…"Venosa""Point(15.816666666 40.96666666…-6440.966667"Q52691""Q6197"
"http://www.wikidata.org/entity…"Sallust""http://www.wikidata.org/entity…"Amiternum""Point(13.305769 42.400776)"-8542.400776"Q177061""Q7170"
"http://www.wikidata.org/entity…"Ovid""http://www.wikidata.org/entity…"Sulmona""Point(13.926198 42.048025)"-4242.048025"Q50157""Q7198"
"http://www.wikidata.org/entity…"Grazia Deledda""http://www.wikidata.org/entity…"Nuoro""Point(9.3280792 40.3200621)"187140.320062"Q13649""Q7728"
"http://www.wikidata.org/entity…"Bronzino""http://www.wikidata.org/entity…"Florence""Point(11.254166666 43.77138888…150343.771389"Q2044""Q7803"
"http://www.wikidata.org/entity…"Sandra Lombardi""http://www.wikidata.org/entity…"Rome""Point(12.482777777 41.89305555…194641.893056"Q220""Q8796"
"http://www.wikidata.org/entity…"Gaius Maecenas Melissus""http://www.wikidata.org/entity…"Spoleto""Point(12.733333333 42.73333333…-10042.733333"Q20571""Q8800"
" ], "text/plain": [ "shape: (10, 9)\n", "┌────────────┬────────────┬───────────┬───────────┬───┬───────────┬───────────┬──────────┬─────────┐\n", "│ subj ┆ subjLabel ┆ place ┆ placeLabe ┆ … ┆ birthyear ┆ latitude ┆ place_id ┆ subj_id │\n", "│ --- ┆ --- ┆ --- ┆ l ┆ ┆ --- ┆ --- ┆ --- ┆ --- │\n", "│ str ┆ str ┆ str ┆ --- ┆ ┆ i64 ┆ f64 ┆ str ┆ str │\n", "│ ┆ ┆ ┆ str ┆ ┆ ┆ ┆ ┆ │\n", "╞════════════╪════════════╪═══════════╪═══════════╪═══╪═══════════╪═══════════╪══════════╪═════════╡\n", "│ http://www ┆ Aemilius ┆ http://ww ┆ Verona ┆ … ┆ null ┆ 45.438611 ┆ Q2028 ┆ Q8797 │\n", "│ .wikidata. ┆ Macer ┆ w.wikidat ┆ ┆ ┆ ┆ ┆ ┆ │\n", "│ org/entity ┆ ┆ a.org/ent ┆ ┆ ┆ ┆ ┆ ┆ │\n", "│ … ┆ ┆ ity… ┆ ┆ ┆ ┆ ┆ ┆ │\n", "│ http://www ┆ Gaius ┆ http://ww ┆ Arezzo ┆ … ┆ null ┆ 43.463056 ┆ Q13378 ┆ Q8833 │\n", "│ .wikidata. ┆ Maecenas ┆ w.wikidat ┆ ┆ ┆ ┆ ┆ ┆ │\n", "│ org/entity ┆ ┆ a.org/ent ┆ ┆ ┆ ┆ ┆ ┆ │\n", "│ … ┆ ┆ ity… ┆ ┆ ┆ ┆ ┆ ┆ │\n", "│ http://www ┆ Michelange ┆ http://ww ┆ Caprese ┆ … ┆ 1475 ┆ 43.640833 ┆ Q52069 ┆ Q5592 │\n", "│ .wikidata. ┆ lo ┆ w.wikidat ┆ Michelang ┆ ┆ ┆ ┆ ┆ │\n", "│ org/entity ┆ ┆ a.org/ent ┆ elo ┆ ┆ ┆ ┆ ┆ │\n", "│ … ┆ ┆ ity… ┆ ┆ ┆ ┆ ┆ ┆ │\n", "│ http://www ┆ Horace ┆ http://ww ┆ Venosa ┆ … ┆ -64 ┆ 40.966667 ┆ Q52691 ┆ Q6197 │\n", "│ .wikidata. ┆ ┆ w.wikidat ┆ ┆ ┆ ┆ ┆ ┆ │\n", "│ org/entity ┆ ┆ a.org/ent ┆ ┆ ┆ ┆ ┆ ┆ │\n", "│ … ┆ ┆ ity… ┆ ┆ ┆ ┆ ┆ ┆ │\n", "│ http://www ┆ Sallust ┆ http://ww ┆ Amiternum ┆ … ┆ -85 ┆ 42.400776 ┆ Q177061 ┆ Q7170 │\n", "│ .wikidata. ┆ ┆ w.wikidat ┆ ┆ ┆ ┆ ┆ ┆ │\n", "│ org/entity ┆ ┆ a.org/ent ┆ ┆ ┆ ┆ ┆ ┆ │\n", "│ … ┆ ┆ ity… ┆ ┆ ┆ ┆ ┆ ┆ │\n", "│ http://www ┆ Ovid ┆ http://ww ┆ Sulmona ┆ … ┆ -42 ┆ 42.048025 ┆ Q50157 ┆ Q7198 │\n", "│ .wikidata. ┆ ┆ w.wikidat ┆ ┆ ┆ ┆ ┆ ┆ │\n", "│ org/entity ┆ ┆ a.org/ent ┆ ┆ ┆ ┆ ┆ ┆ │\n", "│ … ┆ ┆ ity… ┆ ┆ ┆ ┆ ┆ ┆ │\n", "│ http://www ┆ Grazia ┆ http://ww ┆ Nuoro ┆ … ┆ 1871 ┆ 40.320062 ┆ Q13649 ┆ Q7728 │\n", "│ .wikidata. ┆ Deledda ┆ w.wikidat ┆ ┆ ┆ ┆ ┆ ┆ │\n", "│ org/entity ┆ ┆ a.org/ent ┆ ┆ ┆ ┆ ┆ ┆ │\n", "│ … ┆ ┆ ity… ┆ ┆ ┆ ┆ ┆ ┆ │\n", "│ http://www ┆ Bronzino ┆ http://ww ┆ Florence ┆ … ┆ 1503 ┆ 43.771389 ┆ Q2044 ┆ Q7803 │\n", "│ .wikidata. ┆ ┆ w.wikidat ┆ ┆ ┆ ┆ ┆ ┆ │\n", "│ org/entity ┆ ┆ a.org/ent ┆ ┆ ┆ ┆ ┆ ┆ │\n", "│ … ┆ ┆ ity… ┆ ┆ ┆ ┆ ┆ ┆ │\n", "│ http://www ┆ Sandra ┆ http://ww ┆ Rome ┆ … ┆ 1946 ┆ 41.893056 ┆ Q220 ┆ Q8796 │\n", "│ .wikidata. ┆ Lombardi ┆ w.wikidat ┆ ┆ ┆ ┆ ┆ ┆ │\n", "│ org/entity ┆ ┆ a.org/ent ┆ ┆ ┆ ┆ ┆ ┆ │\n", "│ … ┆ ┆ ity… ┆ ┆ ┆ ┆ ┆ ┆ │\n", "│ http://www ┆ Gaius ┆ http://ww ┆ Spoleto ┆ … ┆ -100 ┆ 42.733333 ┆ Q20571 ┆ Q8800 │\n", "│ .wikidata. ┆ Maecenas ┆ w.wikidat ┆ ┆ ┆ ┆ ┆ ┆ │\n", "│ org/entity ┆ Melissus ┆ a.org/ent ┆ ┆ ┆ ┆ ┆ ┆ │\n", "│ … ┆ ┆ ity… ┆ ┆ ┆ ┆ ┆ ┆ │\n", "└────────────┴────────────┴───────────┴───────────┴───┴───────────┴───────────┴──────────┴─────────┘" ] }, "execution_count": null, "metadata": {}, "output_type": "execute_result" } ], "source": [ "first_10" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Born in Verona\n", "\n", "Display all people born in Verona" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "shape: (37, 6)
subjsubjLabelplaceplaceLabelcoordbirthyear
strstrstrstrstri64
"http://www.wikidata.org/entity…"Aemilius Macer""http://www.wikidata.org/entity…"Verona""Point(10.992777777 45.43861111…null
"http://www.wikidata.org/entity…"Catullus""http://www.wikidata.org/entity…"Verona""Point(10.992777777 45.43861111…-83
"http://www.wikidata.org/entity…"Girolamo Fracastoro""http://www.wikidata.org/entity…"Verona""Point(10.992777777 45.43861111…1478
"http://www.wikidata.org/entity…"Guarino da Verona""http://www.wikidata.org/entity…"Verona""Point(10.992777777 45.43861111…1374
"http://www.wikidata.org/entity…"Ippolito Pindemonte""http://www.wikidata.org/entity…"Verona""Point(10.992777777 45.43861111…1753
"http://www.wikidata.org/entity…"Ilario Casarotti""http://www.wikidata.org/entity…"Verona""Point(10.992777777 45.43861111…1772
"http://www.wikidata.org/entity…"Girolamo Orti Manara""http://www.wikidata.org/entity…"Verona""Point(10.992777777 45.43861111…1769
"http://www.wikidata.org/entity…"Paolo Zazzaroni""http://www.wikidata.org/entity…"Verona""Point(10.992777777 45.43861111…null
"http://www.wikidata.org/entity…"Angela Nogarola""http://www.wikidata.org/entity…"Verona""Point(10.992777777 45.43861111…1380
"http://www.wikidata.org/entity…"Bartolomeo Tortoletti""http://www.wikidata.org/entity…"Verona""Point(10.992777777 45.43861111…1560
" ], "text/plain": [ "shape: (37, 6)\n", "┌──────────────────┬──────────────────┬─────────────────┬────────────┬─────────────────┬───────────┐\n", "│ subj ┆ subjLabel ┆ place ┆ placeLabel ┆ coord ┆ birthyear │\n", "│ --- ┆ --- ┆ --- ┆ --- ┆ --- ┆ --- │\n", "│ str ┆ str ┆ str ┆ str ┆ str ┆ i64 │\n", "╞══════════════════╪══════════════════╪═════════════════╪════════════╪═════════════════╪═══════════╡\n", "│ http://www.wikid ┆ Aemilius Macer ┆ http://www.wiki ┆ Verona ┆ Point(10.992777 ┆ null │\n", "│ ata.org/entity… ┆ ┆ data.org/entity ┆ ┆ 777 ┆ │\n", "│ ┆ ┆ … ┆ ┆ 45.43861111… ┆ │\n", "│ http://www.wikid ┆ Catullus ┆ http://www.wiki ┆ Verona ┆ Point(10.992777 ┆ -83 │\n", "│ ata.org/entity… ┆ ┆ data.org/entity ┆ ┆ 777 ┆ │\n", "│ ┆ ┆ … ┆ ┆ 45.43861111… ┆ │\n", "│ http://www.wikid ┆ Girolamo ┆ http://www.wiki ┆ Verona ┆ Point(10.992777 ┆ 1478 │\n", "│ ata.org/entity… ┆ Fracastoro ┆ data.org/entity ┆ ┆ 777 ┆ │\n", "│ ┆ ┆ … ┆ ┆ 45.43861111… ┆ │\n", "│ http://www.wikid ┆ Guarino da ┆ http://www.wiki ┆ Verona ┆ Point(10.992777 ┆ 1374 │\n", "│ ata.org/entity… ┆ Verona ┆ data.org/entity ┆ ┆ 777 ┆ │\n", "│ ┆ ┆ … ┆ ┆ 45.43861111… ┆ │\n", "│ http://www.wikid ┆ Ippolito ┆ http://www.wiki ┆ Verona ┆ Point(10.992777 ┆ 1753 │\n", "│ ata.org/entity… ┆ Pindemonte ┆ data.org/entity ┆ ┆ 777 ┆ │\n", "│ ┆ ┆ … ┆ ┆ 45.43861111… ┆ │\n", "│ … ┆ … ┆ … ┆ … ┆ … ┆ … │\n", "│ http://www.wikid ┆ Ilario Casarotti ┆ http://www.wiki ┆ Verona ┆ Point(10.992777 ┆ 1772 │\n", "│ ata.org/entity… ┆ ┆ data.org/entity ┆ ┆ 777 ┆ │\n", "│ ┆ ┆ … ┆ ┆ 45.43861111… ┆ │\n", "│ http://www.wikid ┆ Girolamo Orti ┆ http://www.wiki ┆ Verona ┆ Point(10.992777 ┆ 1769 │\n", "│ ata.org/entity… ┆ Manara ┆ data.org/entity ┆ ┆ 777 ┆ │\n", "│ ┆ ┆ … ┆ ┆ 45.43861111… ┆ │\n", "│ http://www.wikid ┆ Paolo Zazzaroni ┆ http://www.wiki ┆ Verona ┆ Point(10.992777 ┆ null │\n", "│ ata.org/entity… ┆ ┆ data.org/entity ┆ ┆ 777 ┆ │\n", "│ ┆ ┆ … ┆ ┆ 45.43861111… ┆ │\n", "│ http://www.wikid ┆ Angela Nogarola ┆ http://www.wiki ┆ Verona ┆ Point(10.992777 ┆ 1380 │\n", "│ ata.org/entity… ┆ ┆ data.org/entity ┆ ┆ 777 ┆ │\n", "│ ┆ ┆ … ┆ ┆ 45.43861111… ┆ │\n", "│ http://www.wikid ┆ Bartolomeo ┆ http://www.wiki ┆ Verona ┆ Point(10.992777 ┆ 1560 │\n", "│ ata.org/entity… ┆ Tortoletti ┆ data.org/entity ┆ ┆ 777 ┆ │\n", "│ ┆ ┆ … ┆ ┆ 45.43861111… ┆ │\n", "└──────────────────┴──────────────────┴─────────────────┴────────────┴─────────────────┴───────────┘" ] }, "execution_count": null, "metadata": {}, "output_type": "execute_result" } ], "source": [ "verona_df" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## How many people in Verona\n", "\n", "Display how many people were born in Verona" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "37" ] }, "execution_count": null, "metadata": {}, "output_type": "execute_result" } ], "source": [ "verona_count" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Python is everywhere\n", "\n", "Show poets born in Catania in the year -500 \n", "\n", "* mind the minus\n", "* I swear we did not altered the dataset in any way :-)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "shape: (1, 6)
subjsubjLabelplaceplaceLabelcoordbirthyear
strstrstrstrstri64
"http://www.wikidata.org/entity…"Python of Catana""http://www.wikidata.org/entity…"Catania""Point(15.087269444 37.50266944…-500
" ], "text/plain": [ "shape: (1, 6)\n", "┌────────────────────┬───────────┬────────────────────┬────────────┬───────────────────┬───────────┐\n", "│ subj ┆ subjLabel ┆ place ┆ placeLabel ┆ coord ┆ birthyear │\n", "│ --- ┆ --- ┆ --- ┆ --- ┆ --- ┆ --- │\n", "│ str ┆ str ┆ str ┆ str ┆ str ┆ i64 │\n", "╞════════════════════╪═══════════╪════════════════════╪════════════╪═══════════════════╪═══════════╡\n", "│ http://www.wikidat ┆ Python of ┆ http://www.wikidat ┆ Catania ┆ Point(15.08726944 ┆ -500 │\n", "│ a.org/entity… ┆ Catana ┆ a.org/entity… ┆ ┆ 4 37.50266944… ┆ │\n", "└────────────────────┴───────────┴────────────────────┴────────────┴───────────────────┴───────────┘" ] }, "execution_count": null, "metadata": {}, "output_type": "execute_result" } ], "source": [ "catania_minus_500" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Verona after 1500\n", "\n", "Display all people born in Verona after the year 1500" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "shape: (29, 6)
subjsubjLabelplaceplaceLabelcoordbirthyear
strstrstrstrstri64
"http://www.wikidata.org/entity…"Ippolito Pindemonte""http://www.wikidata.org/entity…"Verona""Point(10.992777777 45.43861111…1753
"http://www.wikidata.org/entity…"Aleardo Aleardi""http://www.wikidata.org/entity…"Verona""Point(10.992777777 45.43861111…1812
"http://www.wikidata.org/entity…"Cristina Ali Farah""http://www.wikidata.org/entity…"Verona""Point(10.992777777 45.43861111…1973
"http://www.wikidata.org/entity…"Francesco Scipione, marchese d…"http://www.wikidata.org/entity…"Verona""Point(10.992777777 45.43861111…1675
"http://www.wikidata.org/entity…"Marco Antonio Zucchi""http://www.wikidata.org/entity…"Verona""Point(10.992777777 45.43861111…1750
"http://www.wikidata.org/entity…"Giambattista Mutinelli""http://www.wikidata.org/entity…"Verona""Point(10.992777777 45.43861111…1747
"http://www.wikidata.org/entity…"Pietro Caliari""http://www.wikidata.org/entity…"Verona""Point(10.992777777 45.43861111…1841
"http://www.wikidata.org/entity…"Ilario Casarotti""http://www.wikidata.org/entity…"Verona""Point(10.992777777 45.43861111…1772
"http://www.wikidata.org/entity…"Girolamo Orti Manara""http://www.wikidata.org/entity…"Verona""Point(10.992777777 45.43861111…1769
"http://www.wikidata.org/entity…"Bartolomeo Tortoletti""http://www.wikidata.org/entity…"Verona""Point(10.992777777 45.43861111…1560
" ], "text/plain": [ "shape: (29, 6)\n", "┌──────────────────┬──────────────────┬─────────────────┬────────────┬─────────────────┬───────────┐\n", "│ subj ┆ subjLabel ┆ place ┆ placeLabel ┆ coord ┆ birthyear │\n", "│ --- ┆ --- ┆ --- ┆ --- ┆ --- ┆ --- │\n", "│ str ┆ str ┆ str ┆ str ┆ str ┆ i64 │\n", "╞══════════════════╪══════════════════╪═════════════════╪════════════╪═════════════════╪═══════════╡\n", "│ http://www.wikid ┆ Ippolito ┆ http://www.wiki ┆ Verona ┆ Point(10.992777 ┆ 1753 │\n", "│ ata.org/entity… ┆ Pindemonte ┆ data.org/entity ┆ ┆ 777 ┆ │\n", "│ ┆ ┆ … ┆ ┆ 45.43861111… ┆ │\n", "│ http://www.wikid ┆ Aleardo Aleardi ┆ http://www.wiki ┆ Verona ┆ Point(10.992777 ┆ 1812 │\n", "│ ata.org/entity… ┆ ┆ data.org/entity ┆ ┆ 777 ┆ │\n", "│ ┆ ┆ … ┆ ┆ 45.43861111… ┆ │\n", "│ http://www.wikid ┆ Cristina Ali ┆ http://www.wiki ┆ Verona ┆ Point(10.992777 ┆ 1973 │\n", "│ ata.org/entity… ┆ Farah ┆ data.org/entity ┆ ┆ 777 ┆ │\n", "│ ┆ ┆ … ┆ ┆ 45.43861111… ┆ │\n", "│ http://www.wikid ┆ Francesco ┆ http://www.wiki ┆ Verona ┆ Point(10.992777 ┆ 1675 │\n", "│ ata.org/entity… ┆ Scipione, ┆ data.org/entity ┆ ┆ 777 ┆ │\n", "│ ┆ marchese d… ┆ … ┆ ┆ 45.43861111… ┆ │\n", "│ http://www.wikid ┆ Marco Antonio ┆ http://www.wiki ┆ Verona ┆ Point(10.992777 ┆ 1750 │\n", "│ ata.org/entity… ┆ Zucchi ┆ data.org/entity ┆ ┆ 777 ┆ │\n", "│ ┆ ┆ … ┆ ┆ 45.43861111… ┆ │\n", "│ … ┆ … ┆ … ┆ … ┆ … ┆ … │\n", "│ http://www.wikid ┆ Giambattista ┆ http://www.wiki ┆ Verona ┆ Point(10.992777 ┆ 1747 │\n", "│ ata.org/entity… ┆ Mutinelli ┆ data.org/entity ┆ ┆ 777 ┆ │\n", "│ ┆ ┆ … ┆ ┆ 45.43861111… ┆ │\n", "│ http://www.wikid ┆ Pietro Caliari ┆ http://www.wiki ┆ Verona ┆ Point(10.992777 ┆ 1841 │\n", "│ ata.org/entity… ┆ ┆ data.org/entity ┆ ┆ 777 ┆ │\n", "│ ┆ ┆ … ┆ ┆ 45.43861111… ┆ │\n", "│ http://www.wikid ┆ Ilario Casarotti ┆ http://www.wiki ┆ Verona ┆ Point(10.992777 ┆ 1772 │\n", "│ ata.org/entity… ┆ ┆ data.org/entity ┆ ┆ 777 ┆ │\n", "│ ┆ ┆ … ┆ ┆ 45.43861111… ┆ │\n", "│ http://www.wikid ┆ Girolamo Orti ┆ http://www.wiki ┆ Verona ┆ Point(10.992777 ┆ 1769 │\n", "│ ata.org/entity… ┆ Manara ┆ data.org/entity ┆ ┆ 777 ┆ │\n", "│ ┆ ┆ … ┆ ┆ 45.43861111… ┆ │\n", "│ http://www.wikid ┆ Bartolomeo ┆ http://www.wiki ┆ Verona ┆ Point(10.992777 ┆ 1560 │\n", "│ ata.org/entity… ┆ Tortoletti ┆ data.org/entity ┆ ┆ 777 ┆ │\n", "│ ┆ ┆ … ┆ ┆ 45.43861111… ┆ │\n", "└──────────────────┴──────────────────┴─────────────────┴────────────┴─────────────────┴───────────┘" ] }, "execution_count": null, "metadata": {}, "output_type": "execute_result" } ], "source": [ "verona_after_1500" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## First Antonio\n", "\n", "Display all people with Antonio as first name" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "shape: (85, 6)
subjsubjLabelplaceplaceLabelcoordbirthyear
strstrstrstrstri64
"http://www.wikidata.org/entity…"Antonio Bonfini""http://www.wikidata.org/entity…"Ancona""Point(13.516666666 43.61666666…1427
"http://www.wikidata.org/entity…"Antonio Bonfini""http://www.wikidata.org/entity…"Patrignone""Point(13.60926 42.98027)"1427
"http://www.wikidata.org/entity…"Antonio Tebaldeo""http://www.wikidata.org/entity…"Ferrara""Point(11.619865 44.835297)"1463
"http://www.wikidata.org/entity…"Antonio Fogazzaro""http://www.wikidata.org/entity…"Vicenza""Point(11.55 45.55)"1842
"http://www.wikidata.org/entity…"Antonio Ghislanzoni""http://www.wikidata.org/entity…"Lecco""Point(9.4 45.85)"1824
"http://www.wikidata.org/entity…"Antonio Bruni""http://www.wikidata.org/entity…"Manduria""Point(17.634166666 40.40277777…1593
"http://www.wikidata.org/entity…"Antonio Decio""http://www.wikidata.org/entity…"Orte""Point(12.386111111 42.46027777…1560
"http://www.wikidata.org/entity…"Antonio Rossetti""http://www.wikidata.org/entity…"Vasto""Point(14.708219444 42.11158888…1770
"http://www.wikidata.org/entity…"Antonio Ricci""http://www.wikidata.org/entity…"Guardiagrele""Point(14.221591666 42.18922222…1952
"http://www.wikidata.org/entity…"Antonio Gasparinetti""http://www.wikidata.org/entity…"Ponte di Piave""Point(12.466666666 45.71666666…1777
" ], "text/plain": [ "shape: (85, 6)\n", "┌─────────────────┬─────────────────┬────────────────┬────────────────┬────────────────┬───────────┐\n", "│ subj ┆ subjLabel ┆ place ┆ placeLabel ┆ coord ┆ birthyear │\n", "│ --- ┆ --- ┆ --- ┆ --- ┆ --- ┆ --- │\n", "│ str ┆ str ┆ str ┆ str ┆ str ┆ i64 │\n", "╞═════════════════╪═════════════════╪════════════════╪════════════════╪════════════════╪═══════════╡\n", "│ http://www.wiki ┆ Antonio Bonfini ┆ http://www.wik ┆ Ancona ┆ Point(13.51666 ┆ 1427 │\n", "│ data.org/entity ┆ ┆ idata.org/enti ┆ ┆ 6666 ┆ │\n", "│ … ┆ ┆ ty… ┆ ┆ 43.61666666… ┆ │\n", "│ http://www.wiki ┆ Antonio Bonfini ┆ http://www.wik ┆ Patrignone ┆ Point(13.60926 ┆ 1427 │\n", "│ data.org/entity ┆ ┆ idata.org/enti ┆ ┆ 42.98027) ┆ │\n", "│ … ┆ ┆ ty… ┆ ┆ ┆ │\n", "│ http://www.wiki ┆ Antonio ┆ http://www.wik ┆ Ferrara ┆ Point(11.61986 ┆ 1463 │\n", "│ data.org/entity ┆ Tebaldeo ┆ idata.org/enti ┆ ┆ 5 44.835297) ┆ │\n", "│ … ┆ ┆ ty… ┆ ┆ ┆ │\n", "│ http://www.wiki ┆ Antonio ┆ http://www.wik ┆ Vicenza ┆ Point(11.55 ┆ 1842 │\n", "│ data.org/entity ┆ Fogazzaro ┆ idata.org/enti ┆ ┆ 45.55) ┆ │\n", "│ … ┆ ┆ ty… ┆ ┆ ┆ │\n", "│ http://www.wiki ┆ Antonio ┆ http://www.wik ┆ Lecco ┆ Point(9.4 ┆ 1824 │\n", "│ data.org/entity ┆ Ghislanzoni ┆ idata.org/enti ┆ ┆ 45.85) ┆ │\n", "│ … ┆ ┆ ty… ┆ ┆ ┆ │\n", "│ … ┆ … ┆ … ┆ … ┆ … ┆ … │\n", "│ http://www.wiki ┆ Antonio Bruni ┆ http://www.wik ┆ Manduria ┆ Point(17.63416 ┆ 1593 │\n", "│ data.org/entity ┆ ┆ idata.org/enti ┆ ┆ 6666 ┆ │\n", "│ … ┆ ┆ ty… ┆ ┆ 40.40277777… ┆ │\n", "│ http://www.wiki ┆ Antonio Decio ┆ http://www.wik ┆ Orte ┆ Point(12.38611 ┆ 1560 │\n", "│ data.org/entity ┆ ┆ idata.org/enti ┆ ┆ 1111 ┆ │\n", "│ … ┆ ┆ ty… ┆ ┆ 42.46027777… ┆ │\n", "│ http://www.wiki ┆ Antonio ┆ http://www.wik ┆ Vasto ┆ Point(14.70821 ┆ 1770 │\n", "│ data.org/entity ┆ Rossetti ┆ idata.org/enti ┆ ┆ 9444 ┆ │\n", "│ … ┆ ┆ ty… ┆ ┆ 42.11158888… ┆ │\n", "│ http://www.wiki ┆ Antonio Ricci ┆ http://www.wik ┆ Guardiagrele ┆ Point(14.22159 ┆ 1952 │\n", "│ data.org/entity ┆ ┆ idata.org/enti ┆ ┆ 1666 ┆ │\n", "│ … ┆ ┆ ty… ┆ ┆ 42.18922222… ┆ │\n", "│ http://www.wiki ┆ Antonio ┆ http://www.wik ┆ Ponte di Piave ┆ Point(12.46666 ┆ 1777 │\n", "│ data.org/entity ┆ Gasparinetti ┆ idata.org/enti ┆ ┆ 6666 ┆ │\n", "│ … ┆ ┆ ty… ┆ ┆ 45.71666666… ┆ │\n", "└─────────────────┴─────────────────┴────────────────┴────────────────┴────────────────┴───────────┘" ] }, "execution_count": null, "metadata": {}, "output_type": "execute_result" } ], "source": [ "first_antonios" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Some Antonio\n", "\n", "Display all people with Antonio as one of the names (so also include `'Paolo Antonio Rolli'`)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "shape: (110, 6)
subjsubjLabelplaceplaceLabelcoordbirthyear
strstrstrstrstri64
"http://www.wikidata.org/entity…"Antonio Bonfini""http://www.wikidata.org/entity…"Ancona""Point(13.516666666 43.61666666…1427
"http://www.wikidata.org/entity…"Antonio Bonfini""http://www.wikidata.org/entity…"Patrignone""Point(13.60926 42.98027)"1427
"http://www.wikidata.org/entity…"Michelangelo Antonioni""http://www.wikidata.org/entity…"Ferrara""Point(11.619865 44.835297)"1912
"http://www.wikidata.org/entity…"Antonio Tebaldeo""http://www.wikidata.org/entity…"Ferrara""Point(11.619865 44.835297)"1463
"http://www.wikidata.org/entity…"Antonio Fogazzaro""http://www.wikidata.org/entity…"Vicenza""Point(11.55 45.55)"1842
"http://www.wikidata.org/entity…"Carlo Antonio Bertelli""http://www.wikidata.org/entity…"Salò""Point(10.533333333 45.6)"1637
"http://www.wikidata.org/entity…"Antonio Decio""http://www.wikidata.org/entity…"Orte""Point(12.386111111 42.46027777…1560
"http://www.wikidata.org/entity…"Antonio Rossetti""http://www.wikidata.org/entity…"Vasto""Point(14.708219444 42.11158888…1770
"http://www.wikidata.org/entity…"Antonio Ricci""http://www.wikidata.org/entity…"Guardiagrele""Point(14.221591666 42.18922222…1952
"http://www.wikidata.org/entity…"Antonio Gasparinetti""http://www.wikidata.org/entity…"Ponte di Piave""Point(12.466666666 45.71666666…1777
" ], "text/plain": [ "shape: (110, 6)\n", "┌─────────────────┬─────────────────┬────────────────┬────────────────┬────────────────┬───────────┐\n", "│ subj ┆ subjLabel ┆ place ┆ placeLabel ┆ coord ┆ birthyear │\n", "│ --- ┆ --- ┆ --- ┆ --- ┆ --- ┆ --- │\n", "│ str ┆ str ┆ str ┆ str ┆ str ┆ i64 │\n", "╞═════════════════╪═════════════════╪════════════════╪════════════════╪════════════════╪═══════════╡\n", "│ http://www.wiki ┆ Antonio Bonfini ┆ http://www.wik ┆ Ancona ┆ Point(13.51666 ┆ 1427 │\n", "│ data.org/entity ┆ ┆ idata.org/enti ┆ ┆ 6666 ┆ │\n", "│ … ┆ ┆ ty… ┆ ┆ 43.61666666… ┆ │\n", "│ http://www.wiki ┆ Antonio Bonfini ┆ http://www.wik ┆ Patrignone ┆ Point(13.60926 ┆ 1427 │\n", "│ data.org/entity ┆ ┆ idata.org/enti ┆ ┆ 42.98027) ┆ │\n", "│ … ┆ ┆ ty… ┆ ┆ ┆ │\n", "│ http://www.wiki ┆ Michelangelo ┆ http://www.wik ┆ Ferrara ┆ Point(11.61986 ┆ 1912 │\n", "│ data.org/entity ┆ Antonioni ┆ idata.org/enti ┆ ┆ 5 44.835297) ┆ │\n", "│ … ┆ ┆ ty… ┆ ┆ ┆ │\n", "│ http://www.wiki ┆ Antonio ┆ http://www.wik ┆ Ferrara ┆ Point(11.61986 ┆ 1463 │\n", "│ data.org/entity ┆ Tebaldeo ┆ idata.org/enti ┆ ┆ 5 44.835297) ┆ │\n", "│ … ┆ ┆ ty… ┆ ┆ ┆ │\n", "│ http://www.wiki ┆ Antonio ┆ http://www.wik ┆ Vicenza ┆ Point(11.55 ┆ 1842 │\n", "│ data.org/entity ┆ Fogazzaro ┆ idata.org/enti ┆ ┆ 45.55) ┆ │\n", "│ … ┆ ┆ ty… ┆ ┆ ┆ │\n", "│ … ┆ … ┆ … ┆ … ┆ … ┆ … │\n", "│ http://www.wiki ┆ Carlo Antonio ┆ http://www.wik ┆ Salò ┆ Point(10.53333 ┆ 1637 │\n", "│ data.org/entity ┆ Bertelli ┆ idata.org/enti ┆ ┆ 3333 45.6) ┆ │\n", "│ … ┆ ┆ ty… ┆ ┆ ┆ │\n", "│ http://www.wiki ┆ Antonio Decio ┆ http://www.wik ┆ Orte ┆ Point(12.38611 ┆ 1560 │\n", "│ data.org/entity ┆ ┆ idata.org/enti ┆ ┆ 1111 ┆ │\n", "│ … ┆ ┆ ty… ┆ ┆ 42.46027777… ┆ │\n", "│ http://www.wiki ┆ Antonio ┆ http://www.wik ┆ Vasto ┆ Point(14.70821 ┆ 1770 │\n", "│ data.org/entity ┆ Rossetti ┆ idata.org/enti ┆ ┆ 9444 ┆ │\n", "│ … ┆ ┆ ty… ┆ ┆ 42.11158888… ┆ │\n", "│ http://www.wiki ┆ Antonio Ricci ┆ http://www.wik ┆ Guardiagrele ┆ Point(14.22159 ┆ 1952 │\n", "│ data.org/entity ┆ ┆ idata.org/enti ┆ ┆ 1666 ┆ │\n", "│ … ┆ ┆ ty… ┆ ┆ 42.18922222… ┆ │\n", "│ http://www.wiki ┆ Antonio ┆ http://www.wik ┆ Ponte di Piave ┆ Point(12.46666 ┆ 1777 │\n", "│ data.org/entity ┆ Gasparinetti ┆ idata.org/enti ┆ ┆ 6666 ┆ │\n", "│ … ┆ ┆ ty… ┆ ┆ 45.71666666… ┆ │\n", "└─────────────────┴─────────────────┴────────────────┴────────────────┴────────────────┴───────────┘" ] }, "execution_count": null, "metadata": {}, "output_type": "execute_result" } ], "source": [ "some_antonio" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Cesares during 1800\n", "\n", "Display all people named Cesare who were born in the 1800s" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "shape: (4, 6)
subjsubjLabelplaceplaceLabelcoordbirthyear
strstrstrstrstri64
"http://www.wikidata.org/entity…"Cesare Meano""http://www.wikidata.org/entity…"Turin""Point(7.7 45.066666666)"1899
"http://www.wikidata.org/entity…"Cesare Betteloni""http://www.wikidata.org/entity…"Verona""Point(10.992777777 45.43861111…1808
"http://www.wikidata.org/entity…"Cesare De Titta""http://www.wikidata.org/entity…"Sant'Eusanio del Sangro""Point(14.333333333 42.16666666…1862
"http://www.wikidata.org/entity…"Cesare Pascarella""http://www.wikidata.org/entity…"Rome""Point(12.482777777 41.89305555…1858
" ], "text/plain": [ "shape: (4, 6)\n", "┌─────────────────┬─────────────────┬────────────────┬────────────────┬────────────────┬───────────┐\n", "│ subj ┆ subjLabel ┆ place ┆ placeLabel ┆ coord ┆ birthyear │\n", "│ --- ┆ --- ┆ --- ┆ --- ┆ --- ┆ --- │\n", "│ str ┆ str ┆ str ┆ str ┆ str ┆ i64 │\n", "╞═════════════════╪═════════════════╪════════════════╪════════════════╪════════════════╪═══════════╡\n", "│ http://www.wiki ┆ Cesare Meano ┆ http://www.wik ┆ Turin ┆ Point(7.7 ┆ 1899 │\n", "│ data.org/entity ┆ ┆ idata.org/enti ┆ ┆ 45.066666666) ┆ │\n", "│ … ┆ ┆ ty… ┆ ┆ ┆ │\n", "│ http://www.wiki ┆ Cesare ┆ http://www.wik ┆ Verona ┆ Point(10.99277 ┆ 1808 │\n", "│ data.org/entity ┆ Betteloni ┆ idata.org/enti ┆ ┆ 7777 ┆ │\n", "│ … ┆ ┆ ty… ┆ ┆ 45.43861111… ┆ │\n", "│ http://www.wiki ┆ Cesare De Titta ┆ http://www.wik ┆ Sant'Eusanio ┆ Point(14.33333 ┆ 1862 │\n", "│ data.org/entity ┆ ┆ idata.org/enti ┆ del Sangro ┆ 3333 ┆ │\n", "│ … ┆ ┆ ty… ┆ ┆ 42.16666666… ┆ │\n", "│ http://www.wiki ┆ Cesare ┆ http://www.wik ┆ Rome ┆ Point(12.48277 ┆ 1858 │\n", "│ data.org/entity ┆ Pascarella ┆ idata.org/enti ┆ ┆ 7777 ┆ │\n", "│ … ┆ ┆ ty… ┆ ┆ 41.89305555… ┆ │\n", "└─────────────────┴─────────────────┴────────────────┴────────────────┴────────────────┴───────────┘" ] }, "execution_count": null, "metadata": {}, "output_type": "execute_result" } ], "source": [ "cesares_1800s" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## The old ones\n", "\n", "Show poets in year of birth order, excluding null values from the result.\n", "\n", "**HINT**: see [is_not_null()](https://docs.pola.rs/api/python/stable/reference/expressions/api/polars.Expr.is_not_null.html)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "shape: (3_070, 6)
subjsubjLabelplaceplaceLabelcoordbirthyear
strstrstrstrstri64
"http://www.wikidata.org/entity…"Stesichorus""http://www.wikidata.org/entity…"Gioia Tauro""Point(15.9 38.433333333)"-629
"http://www.wikidata.org/entity…"Ibycus""http://www.wikidata.org/entity…"Reggio Calabria""Point(15.65 38.114438888)"-600
"http://www.wikidata.org/entity…"Theognis of Megara""http://www.wikidata.org/entity…"Megara Hyblaea""Point(15.18194444 37.20388889)"-569
"http://www.wikidata.org/entity…"Parmenides""http://www.wikidata.org/entity…"Velia""Point(15.154444444 40.15944444…-514
"http://www.wikidata.org/entity…"Python of Catana""http://www.wikidata.org/entity…"Catania""Point(15.087269444 37.50266944…-500
"http://www.wikidata.org/entity…"Giacomo Panicucci""http://www.wikidata.org/entity…"Piombino""Point(10.52212 42.934824)"1985
"http://www.wikidata.org/entity…"Giovanni Bertoglio""http://www.wikidata.org/entity…"Turin""Point(7.7 45.066666666)"1986
"http://www.wikidata.org/entity…"Gio Evan""http://www.wikidata.org/entity…"Molfetta""Point(16.6 41.2)"1988
"http://www.wikidata.org/entity…"Q14922292""http://www.wikidata.org/entity…"Battipaglia""Point(14.983333333 40.61666666…1991
"http://www.wikidata.org/entity…"D.B.P.I.T.""http://www.wikidata.org/entity…"Rome""Point(12.482777777 41.89305555…2000
" ], "text/plain": [ "shape: (3_070, 6)\n", "┌──────────────────┬─────────────┬─────────────────┬─────────────────┬─────────────────┬───────────┐\n", "│ subj ┆ subjLabel ┆ place ┆ placeLabel ┆ coord ┆ birthyear │\n", "│ --- ┆ --- ┆ --- ┆ --- ┆ --- ┆ --- │\n", "│ str ┆ str ┆ str ┆ str ┆ str ┆ i64 │\n", "╞══════════════════╪═════════════╪═════════════════╪═════════════════╪═════════════════╪═══════════╡\n", "│ http://www.wikid ┆ Stesichorus ┆ http://www.wiki ┆ Gioia Tauro ┆ Point(15.9 ┆ -629 │\n", "│ ata.org/entity… ┆ ┆ data.org/entity ┆ ┆ 38.433333333) ┆ │\n", "│ ┆ ┆ … ┆ ┆ ┆ │\n", "│ http://www.wikid ┆ Ibycus ┆ http://www.wiki ┆ Reggio Calabria ┆ Point(15.65 ┆ -600 │\n", "│ ata.org/entity… ┆ ┆ data.org/entity ┆ ┆ 38.114438888) ┆ │\n", "│ ┆ ┆ … ┆ ┆ ┆ │\n", "│ http://www.wikid ┆ Theognis of ┆ http://www.wiki ┆ Megara Hyblaea ┆ Point(15.181944 ┆ -569 │\n", "│ ata.org/entity… ┆ Megara ┆ data.org/entity ┆ ┆ 44 37.20388889) ┆ │\n", "│ ┆ ┆ … ┆ ┆ ┆ │\n", "│ http://www.wikid ┆ Parmenides ┆ http://www.wiki ┆ Velia ┆ Point(15.154444 ┆ -514 │\n", "│ ata.org/entity… ┆ ┆ data.org/entity ┆ ┆ 444 ┆ │\n", "│ ┆ ┆ … ┆ ┆ 40.15944444… ┆ │\n", "│ http://www.wikid ┆ Python of ┆ http://www.wiki ┆ Catania ┆ Point(15.087269 ┆ -500 │\n", "│ ata.org/entity… ┆ Catana ┆ data.org/entity ┆ ┆ 444 ┆ │\n", "│ ┆ ┆ … ┆ ┆ 37.50266944… ┆ │\n", "│ … ┆ … ┆ … ┆ … ┆ … ┆ … │\n", "│ http://www.wikid ┆ Giacomo ┆ http://www.wiki ┆ Piombino ┆ Point(10.52212 ┆ 1985 │\n", "│ ata.org/entity… ┆ Panicucci ┆ data.org/entity ┆ ┆ 42.934824) ┆ │\n", "│ ┆ ┆ … ┆ ┆ ┆ │\n", "│ http://www.wikid ┆ Giovanni ┆ http://www.wiki ┆ Turin ┆ Point(7.7 ┆ 1986 │\n", "│ ata.org/entity… ┆ Bertoglio ┆ data.org/entity ┆ ┆ 45.066666666) ┆ │\n", "│ ┆ ┆ … ┆ ┆ ┆ │\n", "│ http://www.wikid ┆ Gio Evan ┆ http://www.wiki ┆ Molfetta ┆ Point(16.6 ┆ 1988 │\n", "│ ata.org/entity… ┆ ┆ data.org/entity ┆ ┆ 41.2) ┆ │\n", "│ ┆ ┆ … ┆ ┆ ┆ │\n", "│ http://www.wikid ┆ Q14922292 ┆ http://www.wiki ┆ Battipaglia ┆ Point(14.983333 ┆ 1991 │\n", "│ ata.org/entity… ┆ ┆ data.org/entity ┆ ┆ 333 ┆ │\n", "│ ┆ ┆ … ┆ ┆ 40.61666666… ┆ │\n", "│ http://www.wikid ┆ D.B.P.I.T. ┆ http://www.wiki ┆ Rome ┆ Point(12.482777 ┆ 2000 │\n", "│ ata.org/entity… ┆ ┆ data.org/entity ┆ ┆ 777 ┆ │\n", "│ ┆ ┆ … ┆ ┆ 41.89305555… ┆ │\n", "└──────────────────┴─────────────┴─────────────────┴─────────────────┴─────────────────┴───────────┘" ] }, "execution_count": null, "metadata": {}, "output_type": "execute_result" } ], "source": [ "oldest_to_youngest" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Cities of poets\n", "\n", "Find the 5 cities with most poets, sorted from most to least.\n", "\n", "* use `group_by` and `sort` methods" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "shape: (5, 2)
placeLabellen
stru32
"Rome"198
"Florence"165
"Milan"121
"Naples"113
"Venice"94
" ], "text/plain": [ "shape: (5, 2)\n", "┌────────────┬─────┐\n", "│ placeLabel ┆ len │\n", "│ --- ┆ --- │\n", "│ str ┆ u32 │\n", "╞════════════╪═════╡\n", "│ Rome ┆ 198 │\n", "│ Florence ┆ 165 │\n", "│ Milan ┆ 121 │\n", "│ Naples ┆ 113 │\n", "│ Venice ┆ 94 │\n", "└────────────┴─────┘" ] }, "execution_count": null, "metadata": {}, "output_type": "execute_result" } ], "source": [ "poets_cities.head()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Most duplicated poets\n", "\n", "Find first 8 duplicated poets" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "shape: (8, 2)
subjLabellen
stru32
"Giambattista Andreini"4
"Sosiphanes"4
"Eliseo Calenzio"4
"Alojz Rebula"4
"Giovanni della Casa"3
"Aulus Gellius"3
"Tommaso Grossi"3
"Giuseppe Carpani"3
" ], "text/plain": [ "shape: (8, 2)\n", "┌───────────────────────┬─────┐\n", "│ subjLabel ┆ len │\n", "│ --- ┆ --- │\n", "│ str ┆ u32 │\n", "╞═══════════════════════╪═════╡\n", "│ Giambattista Andreini ┆ 4 │\n", "│ Sosiphanes ┆ 4 │\n", "│ Eliseo Calenzio ┆ 4 │\n", "│ Alojz Rebula ┆ 4 │\n", "│ Giovanni della Casa ┆ 3 │\n", "│ Aulus Gellius ┆ 3 │\n", "│ Tommaso Grossi ┆ 3 │\n", "│ Giuseppe Carpani ┆ 3 │\n", "└───────────────────────┴─────┘" ] }, "execution_count": null, "metadata": {}, "output_type": "execute_result" } ], "source": [ "most_duped" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## All duplicated poets\n", "\n", "Print the number of all duplicated poets" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "There are 118 duplicated poets\n" ] } ], "source": [ "print(f\"There are {dups} duplicated poets\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Northern poets\n", "\n", "Find all the poets born north of a given `town`. In other words, look for town latitude (the second coordinate in `coords`), print it, and then filter the table.\n", "\n", "- **DO NOT** put constants like `46.5` in your code!\n", "- Start by extracting the latitudes as a new column.\n", "- **NOTE**: `coord` column holds just simple strings!" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "shape: (14, 7)
subjsubjLabelplaceplaceLabelcoordbirthyearlatitude
strstrstrstrstri64f64
"http://www.wikidata.org/entity…"Oswald von Wolkenstein""http://www.wikidata.org/entity…"Schöneck Castle""Point(11.847977 46.820264)"137746.820264
"http://www.wikidata.org/entity…"Simon Lemnius""http://www.wikidata.org/entity…"Val Müstair""Point(10.39009 46.60566)"151146.60566
"http://www.wikidata.org/entity…"Simon Lemnius""http://www.wikidata.org/entity…"Val Müstair""Point(10.42 46.6)"151146.6
"http://www.wikidata.org/entity…"Mary de Rachewiltz""http://www.wikidata.org/entity…"Brixen""Point(11.65 46.716666666)"192546.716667
"http://www.wikidata.org/entity…"Ignaz Vincenz Zingerle""http://www.wikidata.org/entity…"Merano""Point(11.163888888 46.66888888…182546.668889
"http://www.wikidata.org/entity…"Karl Ziegler""http://www.wikidata.org/entity…"St. Martin in Passeier""Point(11.22727 46.78392)"181246.78392
"http://www.wikidata.org/entity…"Fedele Demetz""http://www.wikidata.org/entity…"Sëlva""Point(11.76038 46.55472)"185046.55472
"http://www.wikidata.org/entity…"Roberta Dapunt""http://www.wikidata.org/entity…"Val Badia""Point(11.89917 46.68361)"197046.68361
"http://www.wikidata.org/entity…"Roberta Dapunt""http://www.wikidata.org/entity…"Val Badia""Point(11.9 46.683333333)"197046.683333
"http://www.wikidata.org/entity…"Anna Katharina Mair""http://www.wikidata.org/entity…"Brixen""Point(11.65 46.716666666)"196746.716667
" ], "text/plain": [ "shape: (14, 7)\n", "┌──────────────┬──────────────┬──────────────┬──────────────┬──────────────┬───────────┬───────────┐\n", "│ subj ┆ subjLabel ┆ place ┆ placeLabel ┆ coord ┆ birthyear ┆ latitude │\n", "│ --- ┆ --- ┆ --- ┆ --- ┆ --- ┆ --- ┆ --- │\n", "│ str ┆ str ┆ str ┆ str ┆ str ┆ i64 ┆ f64 │\n", "╞══════════════╪══════════════╪══════════════╪══════════════╪══════════════╪═══════════╪═══════════╡\n", "│ http://www.w ┆ Oswald von ┆ http://www.w ┆ Schöneck ┆ Point(11.847 ┆ 1377 ┆ 46.820264 │\n", "│ ikidata.org/ ┆ Wolkenstein ┆ ikidata.org/ ┆ Castle ┆ 977 ┆ ┆ │\n", "│ entity… ┆ ┆ entity… ┆ ┆ 46.820264) ┆ ┆ │\n", "│ http://www.w ┆ Simon ┆ http://www.w ┆ Val Müstair ┆ Point(10.390 ┆ 1511 ┆ 46.60566 │\n", "│ ikidata.org/ ┆ Lemnius ┆ ikidata.org/ ┆ ┆ 09 46.60566) ┆ ┆ │\n", "│ entity… ┆ ┆ entity… ┆ ┆ ┆ ┆ │\n", "│ http://www.w ┆ Simon ┆ http://www.w ┆ Val Müstair ┆ Point(10.42 ┆ 1511 ┆ 46.6 │\n", "│ ikidata.org/ ┆ Lemnius ┆ ikidata.org/ ┆ ┆ 46.6) ┆ ┆ │\n", "│ entity… ┆ ┆ entity… ┆ ┆ ┆ ┆ │\n", "│ http://www.w ┆ Mary de ┆ http://www.w ┆ Brixen ┆ Point(11.65 ┆ 1925 ┆ 46.716667 │\n", "│ ikidata.org/ ┆ Rachewiltz ┆ ikidata.org/ ┆ ┆ 46.716666666 ┆ ┆ │\n", "│ entity… ┆ ┆ entity… ┆ ┆ ) ┆ ┆ │\n", "│ http://www.w ┆ Ignaz ┆ http://www.w ┆ Merano ┆ Point(11.163 ┆ 1825 ┆ 46.668889 │\n", "│ ikidata.org/ ┆ Vincenz ┆ ikidata.org/ ┆ ┆ 888888 ┆ ┆ │\n", "│ entity… ┆ Zingerle ┆ entity… ┆ ┆ 46.66888888… ┆ ┆ │\n", "│ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … │\n", "│ http://www.w ┆ Karl Ziegler ┆ http://www.w ┆ St. Martin ┆ Point(11.227 ┆ 1812 ┆ 46.78392 │\n", "│ ikidata.org/ ┆ ┆ ikidata.org/ ┆ in Passeier ┆ 27 46.78392) ┆ ┆ │\n", "│ entity… ┆ ┆ entity… ┆ ┆ ┆ ┆ │\n", "│ http://www.w ┆ Fedele ┆ http://www.w ┆ Sëlva ┆ Point(11.760 ┆ 1850 ┆ 46.55472 │\n", "│ ikidata.org/ ┆ Demetz ┆ ikidata.org/ ┆ ┆ 38 46.55472) ┆ ┆ │\n", "│ entity… ┆ ┆ entity… ┆ ┆ ┆ ┆ │\n", "│ http://www.w ┆ Roberta ┆ http://www.w ┆ Val Badia ┆ Point(11.899 ┆ 1970 ┆ 46.68361 │\n", "│ ikidata.org/ ┆ Dapunt ┆ ikidata.org/ ┆ ┆ 17 46.68361) ┆ ┆ │\n", "│ entity… ┆ ┆ entity… ┆ ┆ ┆ ┆ │\n", "│ http://www.w ┆ Roberta ┆ http://www.w ┆ Val Badia ┆ Point(11.9 ┆ 1970 ┆ 46.683333 │\n", "│ ikidata.org/ ┆ Dapunt ┆ ikidata.org/ ┆ ┆ 46.683333333 ┆ ┆ │\n", "│ entity… ┆ ┆ entity… ┆ ┆ ) ┆ ┆ │\n", "│ http://www.w ┆ Anna ┆ http://www.w ┆ Brixen ┆ Point(11.65 ┆ 1967 ┆ 46.716667 │\n", "│ ikidata.org/ ┆ Katharina ┆ ikidata.org/ ┆ ┆ 46.716666666 ┆ ┆ │\n", "│ entity… ┆ Mair ┆ entity… ┆ ┆ ) ┆ ┆ │\n", "└──────────────┴──────────────┴──────────────┴──────────────┴──────────────┴───────────┴───────────┘" ] }, "execution_count": null, "metadata": {}, "output_type": "execute_result" } ], "source": [ "northern_poets" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Papers please\n", "\n", "Extract subject id (i.e. `Q8797`) and place id (i.e. `Q2028`) and MODIFY `df` by putting them into two new columns `subj_id` and `place_id`" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "shape: (3_198, 9)
subjsubjLabelplaceplaceLabelcoordbirthyearlatitudeplace_idsubj_id
strstrstrstrstri64f64strstr
"http://www.wikidata.org/entity…"Aemilius Macer""http://www.wikidata.org/entity…"Verona""Point(10.992777777 45.43861111…null45.438611"Q2028""Q8797"
"http://www.wikidata.org/entity…"Gaius Maecenas""http://www.wikidata.org/entity…"Arezzo""Point(11.878055555 43.46305555…null43.463056"Q13378""Q8833"
"http://www.wikidata.org/entity…"Michelangelo""http://www.wikidata.org/entity…"Caprese Michelangelo""Point(11.985833333 43.64083333…147543.640833"Q52069""Q5592"
"http://www.wikidata.org/entity…"Horace""http://www.wikidata.org/entity…"Venosa""Point(15.816666666 40.96666666…-6440.966667"Q52691""Q6197"
"http://www.wikidata.org/entity…"Sallust""http://www.wikidata.org/entity…"Amiternum""Point(13.305769 42.400776)"-8542.400776"Q177061""Q7170"
"http://www.wikidata.org/entity…"Giovanni Marrasio""http://www.wikidata.org/entity…"Noto""Point(15.083333333 36.88333333…140536.883333"Q487174""Q99308713"
"http://www.wikidata.org/entity…"Annemarie Innerebner""http://www.wikidata.org/entity…"Bolzano""Point(11.35 46.5)"192446.5"Q6526""Q100775377"
"http://www.wikidata.org/entity…"Nesti Lyro Wollek""http://www.wikidata.org/entity…"Florence""Point(11.254166666 43.77138888…187543.771389"Q2044""Q100775410"
"http://www.wikidata.org/entity…"Lorenza Meletti""http://www.wikidata.org/entity…"Bondeno""Point(11.41542 44.88944)"194044.88944"Q95093""Q99655533"
"http://www.wikidata.org/entity…"Nanni Falconi""http://www.wikidata.org/entity…"Pattada""Point(9.11 40.582222222)"195040.582222"Q391218""Q99912619"
" ], "text/plain": [ "shape: (3_198, 9)\n", "┌───────────┬───────────┬───────────┬───────────┬───┬───────────┬───────────┬──────────┬───────────┐\n", "│ subj ┆ subjLabel ┆ place ┆ placeLabe ┆ … ┆ birthyear ┆ latitude ┆ place_id ┆ subj_id │\n", "│ --- ┆ --- ┆ --- ┆ l ┆ ┆ --- ┆ --- ┆ --- ┆ --- │\n", "│ str ┆ str ┆ str ┆ --- ┆ ┆ i64 ┆ f64 ┆ str ┆ str │\n", "│ ┆ ┆ ┆ str ┆ ┆ ┆ ┆ ┆ │\n", "╞═══════════╪═══════════╪═══════════╪═══════════╪═══╪═══════════╪═══════════╪══════════╪═══════════╡\n", "│ http://ww ┆ Aemilius ┆ http://ww ┆ Verona ┆ … ┆ null ┆ 45.438611 ┆ Q2028 ┆ Q8797 │\n", "│ w.wikidat ┆ Macer ┆ w.wikidat ┆ ┆ ┆ ┆ ┆ ┆ │\n", "│ a.org/ent ┆ ┆ a.org/ent ┆ ┆ ┆ ┆ ┆ ┆ │\n", "│ ity… ┆ ┆ ity… ┆ ┆ ┆ ┆ ┆ ┆ │\n", "│ http://ww ┆ Gaius ┆ http://ww ┆ Arezzo ┆ … ┆ null ┆ 43.463056 ┆ Q13378 ┆ Q8833 │\n", "│ w.wikidat ┆ Maecenas ┆ w.wikidat ┆ ┆ ┆ ┆ ┆ ┆ │\n", "│ a.org/ent ┆ ┆ a.org/ent ┆ ┆ ┆ ┆ ┆ ┆ │\n", "│ ity… ┆ ┆ ity… ┆ ┆ ┆ ┆ ┆ ┆ │\n", "│ http://ww ┆ Michelang ┆ http://ww ┆ Caprese ┆ … ┆ 1475 ┆ 43.640833 ┆ Q52069 ┆ Q5592 │\n", "│ w.wikidat ┆ elo ┆ w.wikidat ┆ Michelang ┆ ┆ ┆ ┆ ┆ │\n", "│ a.org/ent ┆ ┆ a.org/ent ┆ elo ┆ ┆ ┆ ┆ ┆ │\n", "│ ity… ┆ ┆ ity… ┆ ┆ ┆ ┆ ┆ ┆ │\n", "│ http://ww ┆ Horace ┆ http://ww ┆ Venosa ┆ … ┆ -64 ┆ 40.966667 ┆ Q52691 ┆ Q6197 │\n", "│ w.wikidat ┆ ┆ w.wikidat ┆ ┆ ┆ ┆ ┆ ┆ │\n", "│ a.org/ent ┆ ┆ a.org/ent ┆ ┆ ┆ ┆ ┆ ┆ │\n", "│ ity… ┆ ┆ ity… ┆ ┆ ┆ ┆ ┆ ┆ │\n", "│ http://ww ┆ Sallust ┆ http://ww ┆ Amiternum ┆ … ┆ -85 ┆ 42.400776 ┆ Q177061 ┆ Q7170 │\n", "│ w.wikidat ┆ ┆ w.wikidat ┆ ┆ ┆ ┆ ┆ ┆ │\n", "│ a.org/ent ┆ ┆ a.org/ent ┆ ┆ ┆ ┆ ┆ ┆ │\n", "│ ity… ┆ ┆ ity… ┆ ┆ ┆ ┆ ┆ ┆ │\n", "│ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … │\n", "│ http://ww ┆ Giovanni ┆ http://ww ┆ Noto ┆ … ┆ 1405 ┆ 36.883333 ┆ Q487174 ┆ Q99308713 │\n", "│ w.wikidat ┆ Marrasio ┆ w.wikidat ┆ ┆ ┆ ┆ ┆ ┆ │\n", "│ a.org/ent ┆ ┆ a.org/ent ┆ ┆ ┆ ┆ ┆ ┆ │\n", "│ ity… ┆ ┆ ity… ┆ ┆ ┆ ┆ ┆ ┆ │\n", "│ http://ww ┆ Annemarie ┆ http://ww ┆ Bolzano ┆ … ┆ 1924 ┆ 46.5 ┆ Q6526 ┆ Q10077537 │\n", "│ w.wikidat ┆ Innerebne ┆ w.wikidat ┆ ┆ ┆ ┆ ┆ ┆ 7 │\n", "│ a.org/ent ┆ r ┆ a.org/ent ┆ ┆ ┆ ┆ ┆ ┆ │\n", "│ ity… ┆ ┆ ity… ┆ ┆ ┆ ┆ ┆ ┆ │\n", "│ http://ww ┆ Nesti ┆ http://ww ┆ Florence ┆ … ┆ 1875 ┆ 43.771389 ┆ Q2044 ┆ Q10077541 │\n", "│ w.wikidat ┆ Lyro ┆ w.wikidat ┆ ┆ ┆ ┆ ┆ ┆ 0 │\n", "│ a.org/ent ┆ Wollek ┆ a.org/ent ┆ ┆ ┆ ┆ ┆ ┆ │\n", "│ ity… ┆ ┆ ity… ┆ ┆ ┆ ┆ ┆ ┆ │\n", "│ http://ww ┆ Lorenza ┆ http://ww ┆ Bondeno ┆ … ┆ 1940 ┆ 44.88944 ┆ Q95093 ┆ Q99655533 │\n", "│ w.wikidat ┆ Meletti ┆ w.wikidat ┆ ┆ ┆ ┆ ┆ ┆ │\n", "│ a.org/ent ┆ ┆ a.org/ent ┆ ┆ ┆ ┆ ┆ ┆ │\n", "│ ity… ┆ ┆ ity… ┆ ┆ ┆ ┆ ┆ ┆ │\n", "│ http://ww ┆ Nanni ┆ http://ww ┆ Pattada ┆ … ┆ 1950 ┆ 40.582222 ┆ Q391218 ┆ Q99912619 │\n", "│ w.wikidat ┆ Falconi ┆ w.wikidat ┆ ┆ ┆ ┆ ┆ ┆ │\n", "│ a.org/ent ┆ ┆ a.org/ent ┆ ┆ ┆ ┆ ┆ ┆ │\n", "│ ity… ┆ ┆ ity… ┆ ┆ ┆ ┆ ┆ ┆ │\n", "└───────────┴───────────┴───────────┴───────────┴───┴───────────┴───────────┴──────────┴───────────┘" ] }, "execution_count": null, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Unknown poets \n", "\n", "Find all the ids of nameless poets and put them in **a python list**.\n", "\n", "* **DO NOT** use loops\n", "* **NOTE** a Series object from the point of view of Python is just a sequence" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "['Q4360247',\n", " 'Q14922292',\n", " 'Q19130448',\n", " 'Q21207901',\n", " 'Q19984452',\n", " 'Q21209119',\n", " 'Q21282215',\n", " 'Q23673492',\n", " 'Q29049430',\n", " 'Q29052339',\n", " 'Q31763467',\n", " 'Q28465822',\n", " 'Q48809843',\n", " 'Q27553577',\n", " 'Q48811051',\n", " 'Q48861610',\n", " 'Q55441810',\n", " 'Q47468550',\n", " 'Q50327630',\n", " 'Q50330028',\n", " 'Q55897192',\n", " 'Q65019765',\n", " 'Q51845316',\n", " 'Q60838260',\n", " 'Q64433131',\n", " 'Q71684946',\n", " 'Q93338246',\n", " 'Q59187521',\n", " 'Q61136330',\n", " 'Q61450547',\n", " 'Q52107491',\n", " 'Q61790603',\n", " 'Q61791394',\n", " 'Q61827513',\n", " 'Q61895377',\n", " 'Q59851133',\n", " 'Q59851150',\n", " 'Q62066746',\n", " 'Q66736238',\n", " 'Q66921487',\n", " 'Q85421610',\n", " 'Q61080035',\n", " 'Q87068357',\n", " 'Q64031897',\n", " 'Q64167386',\n", " 'Q64364409',\n", " 'Q69818426',\n", " 'Q64512266',\n", " 'Q78162153',\n", " 'Q78499894',\n", " 'Q88264630',\n", " 'Q89674973',\n", " 'Q94998318',\n", " 'Q94325725',\n", " 'Q84138681',\n", " 'Q98102965',\n", " 'Q80705985',\n", " 'Q81100287',\n", " 'Q81738068',\n", " 'Q83643534',\n", " 'Q83808244',\n", " 'Q96097742',\n", " 'Q96245247',\n", " 'Q96248786',\n", " 'Q95485499',\n", " 'Q99196947']" ] }, "execution_count": null, "metadata": {}, "output_type": "execute_result" } ], "source": [ "unknown_poets" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Better unknown poets\n", "\n", "Find all the ids, the birthplace and birthdate of nameless poets born after year 0, and put them in **a python list of dictionaries**.\n", "\n", "* **DO NOT** use loops nor list comprehensions" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[{'subj_id': 'Q4360247', 'birthyear': 1907, 'placeLabel': 'Rome'},\n", " {'subj_id': 'Q14922292', 'birthyear': 1991, 'placeLabel': 'Battipaglia'},\n", " {'subj_id': 'Q19130448', 'birthyear': 1492, 'placeLabel': 'Vicenza'},\n", " {'subj_id': 'Q21209119', 'birthyear': 1711, 'placeLabel': 'Giuliano Teatino'},\n", " {'subj_id': 'Q21282215', 'birthyear': 1590, 'placeLabel': 'Palermo'},\n", " {'subj_id': 'Q29052339', 'birthyear': 1733, 'placeLabel': 'Taranto'},\n", " {'subj_id': 'Q31763467', 'birthyear': 1755, 'placeLabel': 'Caltanissetta'},\n", " {'subj_id': 'Q28465822', 'birthyear': 1700, 'placeLabel': 'Orvieto'},\n", " {'subj_id': 'Q27553577', 'birthyear': 1250, 'placeLabel': 'Cavriana'},\n", " {'subj_id': 'Q48811051', 'birthyear': 1550, 'placeLabel': 'Roccabernarda'},\n", " {'subj_id': 'Q48861610', 'birthyear': 1452, 'placeLabel': 'Vittorio Veneto'},\n", " {'subj_id': 'Q55441810', 'birthyear': 1844, 'placeLabel': 'Vernio'},\n", " {'subj_id': 'Q47468550', 'birthyear': 1607, 'placeLabel': 'Florence'},\n", " {'subj_id': 'Q50327630', 'birthyear': 1700, 'placeLabel': 'Rome'},\n", " {'subj_id': 'Q50330028', 'birthyear': 1680, 'placeLabel': 'Rome'},\n", " {'subj_id': 'Q55897192', 'birthyear': 1872, 'placeLabel': 'Narni'},\n", " {'subj_id': 'Q65019765', 'birthyear': 1853, 'placeLabel': 'Afragola'},\n", " {'subj_id': 'Q59187521', 'birthyear': 1850, 'placeLabel': 'Padua'},\n", " {'subj_id': 'Q61136330', 'birthyear': 1865, 'placeLabel': 'Osilo'},\n", " {'subj_id': 'Q61450547', 'birthyear': 1847, 'placeLabel': 'Siderno'},\n", " {'subj_id': 'Q52107491', 'birthyear': 1680, 'placeLabel': 'Rome'},\n", " {'subj_id': 'Q61790603', 'birthyear': 1857, 'placeLabel': 'Veneto'},\n", " {'subj_id': 'Q61791394',\n", " 'birthyear': 1905,\n", " 'placeLabel': 'Piedimonte del Calvario'},\n", " {'subj_id': 'Q61827513', 'birthyear': 1847, 'placeLabel': 'Grimacco'},\n", " {'subj_id': 'Q61895377', 'birthyear': 1731, 'placeLabel': 'Como'},\n", " {'subj_id': 'Q59851133', 'birthyear': 1883, 'placeLabel': 'Gorizia'},\n", " {'subj_id': 'Q59851150', 'birthyear': 1929, 'placeLabel': 'Trieste'},\n", " {'subj_id': 'Q62066746', 'birthyear': 1926, 'placeLabel': 'Bologna'},\n", " {'subj_id': 'Q66736238', 'birthyear': 1635, 'placeLabel': 'Lucca'},\n", " {'subj_id': 'Q66921487', 'birthyear': 1914, 'placeLabel': 'Alghero'},\n", " {'subj_id': 'Q85421610', 'birthyear': 1869, 'placeLabel': 'Alghero'},\n", " {'subj_id': 'Q61080035', 'birthyear': 1830, 'placeLabel': 'Greci'},\n", " {'subj_id': 'Q87068357', 'birthyear': 1970, 'placeLabel': 'Polla'},\n", " {'subj_id': 'Q64031897', 'birthyear': 1445, 'placeLabel': 'Castel Goffredo'},\n", " {'subj_id': 'Q64167386', 'birthyear': 1930, 'placeLabel': 'Sambiase'},\n", " {'subj_id': 'Q64364409', 'birthyear': 1752, 'placeLabel': 'Corleone'},\n", " {'subj_id': 'Q69818426', 'birthyear': 1923, 'placeLabel': 'Galati Mamertino'},\n", " {'subj_id': 'Q64512266', 'birthyear': 1890, 'placeLabel': 'Rieti'},\n", " {'subj_id': 'Q78162153', 'birthyear': 1985, 'placeLabel': 'Agrigento'},\n", " {'subj_id': 'Q78499894',\n", " 'birthyear': 1932,\n", " 'placeLabel': 'San Giorgio a Cremano'},\n", " {'subj_id': 'Q88264630', 'birthyear': 1930, 'placeLabel': 'Bari'},\n", " {'subj_id': 'Q89674973', 'birthyear': 1939, 'placeLabel': 'Genoa'},\n", " {'subj_id': 'Q94998318', 'birthyear': 1939, 'placeLabel': 'Trieste'},\n", " {'subj_id': 'Q94325725', 'birthyear': 1908, 'placeLabel': 'Orune'},\n", " {'subj_id': 'Q80705985', 'birthyear': 1879, 'placeLabel': 'Patti'},\n", " {'subj_id': 'Q81100287', 'birthyear': 1935, 'placeLabel': 'Lecco'},\n", " {'subj_id': 'Q81738068', 'birthyear': 1940, 'placeLabel': 'Rogolo'},\n", " {'subj_id': 'Q83643534', 'birthyear': 1717, 'placeLabel': 'Alessandria'},\n", " {'subj_id': 'Q83808244',\n", " 'birthyear': 1921,\n", " 'placeLabel': 'Cancello e Arnone'},\n", " {'subj_id': 'Q96097742', 'birthyear': 1982, 'placeLabel': 'Milan'},\n", " {'subj_id': 'Q96245247', 'birthyear': 1919, 'placeLabel': 'Lecce'},\n", " {'subj_id': 'Q96248786', 'birthyear': 1970, 'placeLabel': 'Guardia Lombardi'},\n", " {'subj_id': 'Q95485499',\n", " 'birthyear': 1907,\n", " 'placeLabel': 'Borgo San Martino'},\n", " {'subj_id': 'Q99196947', 'birthyear': 1973, 'placeLabel': 'Tivoli'}]" ] }, "execution_count": null, "metadata": {}, "output_type": "execute_result" } ], "source": [ "better_unknown_poets" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3" }, "toc": { "base_numbering": 1, "nav_menu": {}, "number_sections": false, "sideBar": true, "skip_h1_title": false, "title_cell": "Table of Contents", "title_sidebar": "Contents", "toc_cell": false, "toc_position": { "height": "calc(100% - 180px)", "left": "10px", "top": "150px", "width": "280.2px" }, "toc_section_display": true, "toc_window_display": true } }, "nbformat": 4, "nbformat_minor": 4 }