Los premios Nobel se anuncian durante una semana en octubre y la ceremonia de entrega es hoy, 10 de diciembre ("en Australia ya es mañana"). Hay una interesante historia de cómo C. V. Raman (de Efecto Raman) reservado su billete a Estocolmo para la ceremonia de entrega de premios del 10 de diciembre incluso antes del anuncio, porque confiaba en ganar el premio.
Obtuve este conjunto de datos del repositorio "Awesome JSON Datasets" en https://github.com/jdorfman/awesome-json-datasets
El conjunto de datos del Premio Nobel tiene tres archivos de datos:
- Laureados - contiene el perfil de cada galardonado.
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
{ "born": "1888-11-07", "bornCity": "Tiruchirappalli", "bornCountry": "India", "bornCountryCode": "IN", "died": "1970-11-21", "diedCity": "Bangalore", "diedCountry": "India", "diedCountryCode": "IN", "firstname": "Sir Chandrasekhara Venkata", "gender": "male", "id": "37", "prizes": [ { "affiliations": [ { "city": "Calcutta", "country": "India", "name": "Calcutta University" } ], "category": "physics", "motivation": "\"for his work on the scattering of light and for the discovery of the effect named after him\"", "share": "1", "year": "1930" } ], "surname": "Raman" } |
- País - Lista de países y código de país
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
{ "code": "AR", "name": "Argentina" }, { "code": "AU", "name": "Australia" }, { "code": "AT", "name": "Austria" }, |
- Premio - la lista de cada premio por año y el ganador agrupado.
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
{ "category": "physics", "laureates": [ { "firstname": "Sin-Itiro", "id": "84", "motivation": "\"for their fundamental work in quantum electrodynamics, with deep-ploughing consequences for the physics of elementary particles\"", "share": "3", "surname": "Tomonaga" }, { "firstname": "Julian", "id": "85", "motivation": "\"for their fundamental work in quantum electrodynamics, with deep-ploughing consequences for the physics of elementary particles\"", "share": "3", "surname": "Schwinger" }, { "firstname": "Richard P.", "id": "86", "motivation": "\"for their fundamental work in quantum electrodynamics, with deep-ploughing consequences for the physics of elementary particles\"", "share": "3", "surname": "Feynman" } ], "year": "1965" } |
El documento del premio tiene un ID que enlaza con el documento individual del ganador en el documento del galardonado. Veamos los premios Nobel. En primer lugar, observe que la información sobre los premios es PLURAL y se almacena en una matriz. Una persona o una organización puede ganar más de un premio. Veamos quiénes han ganado más de un premio.
Tarea 1. ¿Cuántos han ganado más de un premio Nobel?
Consulta 1: Simplemente UNNEST la matriz de laureados para obtener el objeto individual de los ganadores del premio y luego simplemente determinar y filtrar por la longitud de la matriz. Hay una entrada por premio. Para más información sobre el manejo de matrices y las operaciones UNNEST, consulte el artículo: Trabajando con Arrays JSON en N1QL.
|
1 2 3 4 5 6 7 |
select llist.firstname || " " || IFMISSING(llist.surname, ""), array_length(llist.prizes) numnobel from laureate l unnest l.laureates llist where array_length(llist.prizes) > 1; |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
[ { "$1": "Marie Curie, née Sklodowska", "numnobel": 2 }, { "$1": "John Bardeen", "numnobel": 2 }, { "$1": "Linus Carl Pauling", "numnobel": 2 }, { "$1": "Frederick Sanger", "numnobel": 2 }, { "$1": "Comité international de la Croix Rouge (International Committee of the Red Cross) ", "numnobel": 3 }, { "$1": "Office of the United Nations High Commissioner for Refugees (UNHCR) ", "numnobel": 2 } ] |
Tarea 2: Determinar qué país ha producido el mayor número de premios Nobel.
Consulta 2: simplemente anule los laureados y agrúpelos por el campo bornCountry.
|
1 2 3 4 5 6 7 8 9 |
select llist.bornCountry, Count(1) totalPrizes from laureate l unnest l.laureates llist group by llist.bornCountry order by totalPrizes desc |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
[ { "bornCountry": "USA", "totalPrizes": 269 }, { "bornCountry": "United Kingdom", "totalPrizes": 84 }, { "bornCountry": "Germany", "totalPrizes": 63 }, { "bornCountry": "France", "totalPrizes": 52 }, { "totalPrizes": 33 }, { "bornCountry": "Sweden", "totalPrizes": 29 }, |
Ahora, hay 33 ganadores sin país ni origen... ¿Qué está pasando aquí?
|
1 2 3 4 5 6 7 |
select llist.firstname || " " || IFMISSING(llist.surname, ""), llist.gender from laureate l unnest l.laureates llist where llist.bornCountry is missing; |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 |
{ "$1": "Institut de droit international (Institute of International Law) ", "gender": "org" }, { "$1": "Bureau international permanent de la Paix (Permanent International Peace Bureau) ", "gender": "org" }, { "$1": "Comité international de la Croix Rouge (International Committee of the Red Cross) ", "gender": "org" }, ... |
Parece que se trata de organizaciones internacionales y luego un par de ganadores cuyos datos faltan bornCountry.
Tarea 3: Cuántos han venido de la India.
Pregunta 3: Los premios Nobel se conceden desde 1901, pero India obtuvo su independencia en 1947. Hasta 1947, el país de nacimiento tiene como etiqueta "British India". Hagamos una búsqueda ampliada.
|
1 2 3 4 5 6 7 8 9 10 11 12 |
select llist.firstname, llist.surname, llist.bornCountry as xborncountry, llist.diedCountry as ydiedcountry, llist.gender as zgender from laureate l unnest l.laureates llist where llist.bornCountry = "India" or lower(llist.bornCountry) like "%india%" or llist.diedCountry = "India" |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
[ { "firstname": "Sir Chandrasekhara Venkata", "surname": "Raman", "xborncountry": "India", "ydiedcountry": "India", "zgender": "male" }, { "firstname": "Abdus", "surname": "Salam", "xborncountry": "India (now Pakistan)", "ydiedcountry": "United Kingdom", "zgender": "male" }, { "firstname": "Subramanyan", "surname": "Chandrasekhar", "xborncountry": "India (now Pakistan)", "ydiedcountry": "USA", "zgender": "male" }, { "firstname": "Ronald", "surname": "Ross", "xborncountry": "India", "ydiedcountry": "United Kingdom", "zgender": "male" }, { "firstname": "Har Gobind", "surname": "Khorana", "xborncountry": "India", "ydiedcountry": "USA", "zgender": "male" }, { "firstname": "Mother Teresa", "xborncountry": "Ottoman Empire (now Republic of Macedonia)", "ydiedcountry": "India", "zgender": "female" }, { "firstname": "Rudyard", "surname": "Kipling", "xborncountry": "British India (now India)", "ydiedcountry": "United Kingdom", "zgender": "male" }, { "firstname": "Rabindranath", "surname": "Tagore", "xborncountry": "India", "ydiedcountry": "India", "zgender": "male" }, { "firstname": "Amartya", "surname": "Sen", "xborncountry": "India", "zgender": "male" }, { "firstname": "Muhammad", "surname": "Yunus", "xborncountry": "British India (now Bangladesh)", "zgender": "male" }, { "firstname": "Venkatraman", "surname": "Ramakrishnan", "xborncountry": "India", "zgender": "male" }, { "firstname": "Kailash", "surname": "Satyarthi", "xborncountry": "India", "zgender": "male" } ] |
Resultados sorprendentes Además de los conocidos Premios Nobel indios, un par de famosos ganadores británicos, entre ellos Rudyard Kipling, nacieron en la India. Sólo hay un ganador que no nació en la India pero murió allí: La Madre Teresa.
Descubramos las categorías.
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
select lp.category, COUNT(1) prizecount from laureate l unnest l.laureates llist unnest llist.prizes lp where llist.bornCountry = "India" or lower(llist.bornCountry) like "%india%" or llist.diedCountry = "India" or lower(llist.diedCountry) like "%india%" group by lp.category order by prizecount DESC |
|
1 2 3 4 5 6 7 |
category prizecount peace 3 physics 3 literature 2 medicine 2 economics 1 chemistry 1 |
Tarea 4: Crear un gráfico apilado de los 7 países que más premios Nobel han ganado con categofy
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
select llist.bornCountry as xborncountry, lp.category ycategory, COUNT(1) zprizecount, SUM(COUNT(1)) OVER(partition by llist.bornCountry) z1countrytot, SUM(COUNT(1)) OVER( partition by llist.bornCountry order by lp.category ) z1ctrycatcount from laureate l unnest l.laureates llist unnest llist.prizes lp group by llist.bornCountry, lp.category order by z1countrytot desc, ycategory |
Resultados (subconjunto para abreviar)

A partir de aquí, vamos a crear un gráfico de columnas apiladas de los 7 primeros países y mostrar los premios por categoría.

Todas estas manipulaciones de datos son para divertirse y aprender. Pero, el progreso y la paz que estos ganadores han logrado sin fronteras.
Puede descargar el conjunto de datos y Couchbase. A continuación, formula tus propias preguntas interesantes y respóndelas.