Os prêmios Nobel são anunciados durante uma semana em outubro e a cerimônia de premiação é hoje, 10 de dezembro ("Já é amanhã na Austrália"). Há uma história interessante sobre como C. V. Raman (de Efeito Raman) reservado sua passagem para Estocolmo para a cerimônia de premiação de 10 de dezembro, mesmo antes do anúncio, porque ele estava confiante de que ganharia o prêmio!
Obtive esse conjunto de dados do repositório "Awesome JSON Datasets" em https://github.com/jdorfman/awesome-json-datasets
O conjunto de dados do Prêmio Nobel tem três arquivos de dados:
- Laureados - contém o perfil de cada laureado.
|
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 e o código do 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" }, |
- Prêmio - a lista de cada prêmio por ano e o vencedor agrupados.
|
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" } |
O documento do prêmio tem um ID vinculado ao documento do vencedor individual no documento do laureado. Vamos dar uma olhada nos ganhadores do Prêmio Nobel. Primeiro, observe que as informações sobre os prêmios são PLURAIS e estão armazenadas em uma matriz. Uma pessoa ou uma organização pode ganhar mais de um prêmio. Vamos ver quem ganhou mais de um prêmio.
Tarefa 1. Quantos ganharam mais de um prêmio Nobel?
Consulta 1: Basta UNNESTar a matriz de laureados para obter o objeto dos vencedores dos prêmios individuais e, em seguida, determinar e filtrar pelo comprimento da matriz. Há uma entrada por prêmio. Para saber mais sobre o manuseio de matrizes e operações UNNEST, consulte o artigo: Trabalhando com matrizes JSON no 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 } ] |
Tarefa 2: Determine qual país produziu o maior número de ganhadores do Prêmio Nobel.
Consulta 2: Simplesmente anule os laureados e agrupe pelo 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 }, |
Agora, há 33 vencedores sem um país ou origem... O que está acontecendo aqui?
|
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" }, ... |
Essas parecem ser organizações internacionais e, em seguida, alguns vencedores cujos dados estão faltando no bornCountry.
Tarefa 3: Quantos vieram da Índia.
Pergunta 3: Os prêmios Nobel são concedidos desde 1901, mas a Índia obteve sua independência em 1947. Até 1947, o país de origem tinha "Índia Britânica" como rótulo. Vamos fazer uma pesquisa 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" } ] |
Alguns resultados surpreendentes! Além dos conhecidos ganhadores indianos do Prêmio Nobel, alguns ganhadores famosos do Reino Unido, incluindo Rudyard Kipling, nasceram na Índia. Há apenas um ganhador que não nasceu na Índia, mas morreu lá: Madre Teresa.
Vamos descobrir as categorias.
|
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 |
Tarefa 4: Crie um gráfico empilhado dos 7 países que mais ganharam prêmios Nobel com categoria
|
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 fins de brevidade)

A partir disso, vamos criar um gráfico de colunas empilhadas dos sete principais países e mostrar os prêmios por categoria.

Todas essas manipulações de dados são para diversão e aprendizado. Mas o progresso e a paz que esses vencedores alcançaram sem fronteiras.
Você pode fazer o download do conjunto de dados e Couchbase. Em seguida, faça suas próprias perguntas interessantes e responda-as!