{ "cells": [ { "cell_type": "markdown", "id": "c03b8c50", "metadata": {}, "source": [ "# Pandas DataFrames\n", "\n", "\n", "Today, we're going to explore {term}`DataFrame`s in greater detail. We'll continue using\n", "that same coffee dataset." ] }, { "cell_type": "code", "execution_count": 1, "id": "e1b10957", "metadata": {}, "outputs": [], "source": [ "coffee_data_url = 'https://raw.githubusercontent.com/jldbc/coffee-quality-database/master/data/robusta_data_cleaned.csv'" ] }, { "cell_type": "markdown", "id": "02a9b764", "metadata": {}, "source": [ "## More about loading libraries\n", "We can import pandas without the alias `pd` if we want, but then we have to use\n", "the full name everywhere" ] }, { "cell_type": "code", "execution_count": 2, "id": "a0ffb0fc", "metadata": {}, "outputs": [], "source": [ "import pandas" ] }, { "cell_type": "code", "execution_count": 3, "id": "e4f93ea3", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
Unnamed: 0SpeciesOwnerCountry.of.OriginFarm.NameLot.NumberMillICO.NumberCompanyAltitude...ColorCategory.Two.DefectsExpirationCertification.BodyCertification.AddressCertification.Contactunit_of_measurementaltitude_low_metersaltitude_high_metersaltitude_mean_meters
01Robustaankole coffee producers coopUgandakyangundu cooperative societyNaNankole coffee producers0ankole coffee producers coop1488...Green2June 26th, 2015Uganda Coffee Development Authoritye36d0270932c3b657e96b7b0278dfd85dc0fe74303077a1c6bac60e6f514691634a7f6eb5c85aae8m1488.01488.01488.0
12Robustanishant gurjerIndiasethuraman estate kaapi royale25sethuraman estate14/1148/2017/21kaapi royale3170...NaN2October 31st, 2018Specialty Coffee Associationff7c18ad303d4b603ac3f8cff7e611ffc735e720352d0cf7f3e9be14dad7df644ad65efc27605ae2m3170.03170.03170.0
23Robustaandrew hetzelIndiasethuraman estateNaNNaN0000sethuraman estate1000m...Green0April 29th, 2016Specialty Coffee Associationff7c18ad303d4b603ac3f8cff7e611ffc735e720352d0cf7f3e9be14dad7df644ad65efc27605ae2m1000.01000.01000.0
34RobustaugacofUgandaugacof project areaNaNugacof0ugacof ltd1212...Green7July 14th, 2015Uganda Coffee Development Authoritye36d0270932c3b657e96b7b0278dfd85dc0fe74303077a1c6bac60e6f514691634a7f6eb5c85aae8m1212.01212.01212.0
45Robustakatuka development trust ltdUgandakatikamu capca farmers associationNaNkatuka development trust0katuka development trust ltd1200-1300...Green3June 26th, 2015Uganda Coffee Development Authoritye36d0270932c3b657e96b7b0278dfd85dc0fe74303077a1c6bac60e6f514691634a7f6eb5c85aae8m1200.01300.01250.0
56Robustaandrew hetzelIndiaNaNNaN(self)NaNcafemakers, llc3000'...Green0February 28th, 2013Specialty Coffee Associationff7c18ad303d4b603ac3f8cff7e611ffc735e720352d0cf7f3e9be14dad7df644ad65efc27605ae2m3000.03000.03000.0
67Robustaandrew hetzelIndiasethuraman estatesNaNNaNNaNcafemakers750m...Green0May 15th, 2015Specialty Coffee Associationff7c18ad303d4b603ac3f8cff7e611ffc735e720352d0cf7f3e9be14dad7df644ad65efc27605ae2m750.0750.0750.0
78Robustanishant gurjerIndiasethuraman estate kaapi royale7sethuraman estate14/1148/2017/18kaapi royale3140...Bluish-Green0October 25th, 2018Specialty Coffee Associationff7c18ad303d4b603ac3f8cff7e611ffc735e720352d0cf7f3e9be14dad7df644ad65efc27605ae2m3140.03140.03140.0
89Robustanishant gurjerIndiasethuraman estateRKRsethuraman estate14/1148/2016/17kaapi royale1000...Green0August 17th, 2017Specialty Coffee Associationff7c18ad303d4b603ac3f8cff7e611ffc735e720352d0cf7f3e9be14dad7df644ad65efc27605ae2m1000.01000.01000.0
910RobustaugacofUgandaishakaNaNnsubuga umar0ugacof ltd900-1300...Green6August 5th, 2015Uganda Coffee Development Authoritye36d0270932c3b657e96b7b0278dfd85dc0fe74303077a1c6bac60e6f514691634a7f6eb5c85aae8m900.01300.01100.0
1011RobustaugacofUgandaugacof project areaNaNugacof0ugacof ltd1095...Green1June 26th, 2015Uganda Coffee Development Authoritye36d0270932c3b657e96b7b0278dfd85dc0fe74303077a1c6bac60e6f514691634a7f6eb5c85aae8m1095.01095.01095.0
1112Robustanishant gurjerIndiasethuraman estate kaapi royaleRC ABsethuraman estate14/1148/2016/12kaapi royale1000...Green0August 23rd, 2017Specialty Coffee Associationff7c18ad303d4b603ac3f8cff7e611ffc735e720352d0cf7f3e9be14dad7df644ad65efc27605ae2m1000.01000.01000.0
1213Robustaandrew hetzelIndiasethuraman estatesNaNNaNNaNcafemakers750m...Green1May 19th, 2015Specialty Coffee Associationff7c18ad303d4b603ac3f8cff7e611ffc735e720352d0cf7f3e9be14dad7df644ad65efc27605ae2m750.0750.0750.0
1314Robustakasozi coffee farmers associationUgandakasozi coffee farmersNaNNaN0kasozi coffee farmers association1367...Green7July 14th, 2015Uganda Coffee Development Authoritye36d0270932c3b657e96b7b0278dfd85dc0fe74303077a1c6bac60e6f514691634a7f6eb5c85aae8m1367.01367.01367.0
1415Robustaankole coffee producers coopUgandakyangundu coop societyNaNankole coffee producers coop union ltd0ankole coffee producers coop1488...Green2July 14th, 2015Uganda Coffee Development Authoritye36d0270932c3b657e96b7b0278dfd85dc0fe74303077a1c6bac60e6f514691634a7f6eb5c85aae8m1488.01488.01488.0
1516Robustaandrew hetzelIndiasethuraman estateNaNNaN0000sethuraman estate1000m...Green0April 29th, 2016Specialty Coffee Associationff7c18ad303d4b603ac3f8cff7e611ffc735e720352d0cf7f3e9be14dad7df644ad65efc27605ae2m1000.01000.01000.0
1617Robustaandrew hetzelIndiasethuraman estatesNaNsethuraman estatesNaNcafemakers, llc750m...Blue-Green0June 3rd, 2014Specialty Coffee Associationff7c18ad303d4b603ac3f8cff7e611ffc735e720352d0cf7f3e9be14dad7df644ad65efc27605ae2m750.0750.0750.0
1718Robustakawacom uganda ltdUgandabushenyiNaNkawacom0kawacom uganda ltd1600...Green1June 27th, 2015Uganda Coffee Development Authoritye36d0270932c3b657e96b7b0278dfd85dc0fe74303077a1c6bac60e6f514691634a7f6eb5c85aae8m1600.01600.01600.0
1819Robustanitubaasa ltdUgandakigezi coffee farmers associationNaNnitubaasa0nitubaasa ltd1745...Green2June 27th, 2015Uganda Coffee Development Authoritye36d0270932c3b657e96b7b0278dfd85dc0fe74303077a1c6bac60e6f514691634a7f6eb5c85aae8m1745.01745.01745.0
1920Robustamannya coffee projectUgandamannya coffee projectNaNmannya coffee project0mannya coffee project1200...Green1June 27th, 2015Uganda Coffee Development Authoritye36d0270932c3b657e96b7b0278dfd85dc0fe74303077a1c6bac60e6f514691634a7f6eb5c85aae8m1200.01200.01200.0
2021Robustaandrew hetzelIndiasethuraman estatesNaNNaNNaNcafemakers750m...Bluish-Green1May 19th, 2015Specialty Coffee Associationff7c18ad303d4b603ac3f8cff7e611ffc735e720352d0cf7f3e9be14dad7df644ad65efc27605ae2m750.0750.0750.0
2122Robustaandrew hetzelIndiasethuraman estatesNaNsethuraman estatesNaNcafemakers, llc750m...Green0June 20th, 2014Specialty Coffee Associationff7c18ad303d4b603ac3f8cff7e611ffc735e720352d0cf7f3e9be14dad7df644ad65efc27605ae2m750.0750.0750.0
2223Robustaandrew hetzelUnited Statessethuraman estatesNaNsethuraman estatesNaNcafemakers, llc3000'...Green0February 28th, 2013Specialty Coffee Associationff7c18ad303d4b603ac3f8cff7e611ffc735e720352d0cf7f3e9be14dad7df644ad65efc27605ae2m3000.03000.03000.0
2324Robustaluis roblesEcuadorrobustasaLavado 1our own labNaNrobustasaNaN...Blue-Green1January 18th, 2017Specialty Coffee Associationff7c18ad303d4b603ac3f8cff7e611ffc735e720352d0cf7f3e9be14dad7df644ad65efc27605ae2mNaNNaNNaN
2425Robustaluis roblesEcuadorrobustasaLavado 3own laboratoryNaNrobustasa40...Blue-Green0January 18th, 2017Specialty Coffee Associationff7c18ad303d4b603ac3f8cff7e611ffc735e720352d0cf7f3e9be14dad7df644ad65efc27605ae2m40.040.040.0
2526Robustajames mooreUnited Statesfazenda cazengoNaNcafe cazengoNaNglobal opportunity fund795 meters...NaN6December 23rd, 2015Specialty Coffee Associationff7c18ad303d4b603ac3f8cff7e611ffc735e720352d0cf7f3e9be14dad7df644ad65efc27605ae2m795.0795.0795.0
2627Robustacafe politicoIndiaNaNNaNNaN14-1118-2014-0087cafe politicoNaN...Green1August 25th, 2015Specialty Coffee Associationff7c18ad303d4b603ac3f8cff7e611ffc735e720352d0cf7f3e9be14dad7df644ad65efc27605ae2mNaNNaNNaN
2728Robustacafe politicoVietnamNaNNaNNaNNaNcafe politicoNaN...None9August 25th, 2015Specialty Coffee Associationff7c18ad303d4b603ac3f8cff7e611ffc735e720352d0cf7f3e9be14dad7df644ad65efc27605ae2mNaNNaNNaN
\n", "

28 rows × 44 columns

\n", "
" ], "text/plain": [ " Unnamed: 0 Species Owner Country.of.Origin \\\n", "0 1 Robusta ankole coffee producers coop Uganda \n", "1 2 Robusta nishant gurjer India \n", "2 3 Robusta andrew hetzel India \n", "3 4 Robusta ugacof Uganda \n", "4 5 Robusta katuka development trust ltd Uganda \n", "5 6 Robusta andrew hetzel India \n", "6 7 Robusta andrew hetzel India \n", "7 8 Robusta nishant gurjer India \n", "8 9 Robusta nishant gurjer India \n", "9 10 Robusta ugacof Uganda \n", "10 11 Robusta ugacof Uganda \n", "11 12 Robusta nishant gurjer India \n", "12 13 Robusta andrew hetzel India \n", "13 14 Robusta kasozi coffee farmers association Uganda \n", "14 15 Robusta ankole coffee producers coop Uganda \n", "15 16 Robusta andrew hetzel India \n", "16 17 Robusta andrew hetzel India \n", "17 18 Robusta kawacom uganda ltd Uganda \n", "18 19 Robusta nitubaasa ltd Uganda \n", "19 20 Robusta mannya coffee project Uganda \n", "20 21 Robusta andrew hetzel India \n", "21 22 Robusta andrew hetzel India \n", "22 23 Robusta andrew hetzel United States \n", "23 24 Robusta luis robles Ecuador \n", "24 25 Robusta luis robles Ecuador \n", "25 26 Robusta james moore United States \n", "26 27 Robusta cafe politico India \n", "27 28 Robusta cafe politico Vietnam \n", "\n", " Farm.Name Lot.Number \\\n", "0 kyangundu cooperative society NaN \n", "1 sethuraman estate kaapi royale 25 \n", "2 sethuraman estate NaN \n", "3 ugacof project area NaN \n", "4 katikamu capca farmers association NaN \n", "5 NaN NaN \n", "6 sethuraman estates NaN \n", "7 sethuraman estate kaapi royale 7 \n", "8 sethuraman estate RKR \n", "9 ishaka NaN \n", "10 ugacof project area NaN \n", "11 sethuraman estate kaapi royale RC AB \n", "12 sethuraman estates NaN \n", "13 kasozi coffee farmers NaN \n", "14 kyangundu coop society NaN \n", "15 sethuraman estate NaN \n", "16 sethuraman estates NaN \n", "17 bushenyi NaN \n", "18 kigezi coffee farmers association NaN \n", "19 mannya coffee project NaN \n", "20 sethuraman estates NaN \n", "21 sethuraman estates NaN \n", "22 sethuraman estates NaN \n", "23 robustasa Lavado 1 \n", "24 robustasa Lavado 3 \n", "25 fazenda cazengo NaN \n", "26 NaN NaN \n", "27 NaN NaN \n", "\n", " Mill ICO.Number \\\n", "0 ankole coffee producers 0 \n", "1 sethuraman estate 14/1148/2017/21 \n", "2 NaN 0000 \n", "3 ugacof 0 \n", "4 katuka development trust 0 \n", "5 (self) NaN \n", "6 NaN NaN \n", "7 sethuraman estate 14/1148/2017/18 \n", "8 sethuraman estate 14/1148/2016/17 \n", "9 nsubuga umar 0 \n", "10 ugacof 0 \n", "11 sethuraman estate 14/1148/2016/12 \n", "12 NaN NaN \n", "13 NaN 0 \n", "14 ankole coffee producers coop union ltd 0 \n", "15 NaN 0000 \n", "16 sethuraman estates NaN \n", "17 kawacom 0 \n", "18 nitubaasa 0 \n", "19 mannya coffee project 0 \n", "20 NaN NaN \n", "21 sethuraman estates NaN \n", "22 sethuraman estates NaN \n", "23 our own lab NaN \n", "24 own laboratory NaN \n", "25 cafe cazengo NaN \n", "26 NaN 14-1118-2014-0087 \n", "27 NaN NaN \n", "\n", " Company Altitude ... Color \\\n", "0 ankole coffee producers coop 1488 ... Green \n", "1 kaapi royale 3170 ... NaN \n", "2 sethuraman estate 1000m ... Green \n", "3 ugacof ltd 1212 ... Green \n", "4 katuka development trust ltd 1200-1300 ... Green \n", "5 cafemakers, llc 3000' ... Green \n", "6 cafemakers 750m ... Green \n", "7 kaapi royale 3140 ... Bluish-Green \n", "8 kaapi royale 1000 ... Green \n", "9 ugacof ltd 900-1300 ... Green \n", "10 ugacof ltd 1095 ... Green \n", "11 kaapi royale 1000 ... Green \n", "12 cafemakers 750m ... Green \n", "13 kasozi coffee farmers association 1367 ... Green \n", "14 ankole coffee producers coop 1488 ... Green \n", "15 sethuraman estate 1000m ... Green \n", "16 cafemakers, llc 750m ... Blue-Green \n", "17 kawacom uganda ltd 1600 ... Green \n", "18 nitubaasa ltd 1745 ... Green \n", "19 mannya coffee project 1200 ... Green \n", "20 cafemakers 750m ... Bluish-Green \n", "21 cafemakers, llc 750m ... Green \n", "22 cafemakers, llc 3000' ... Green \n", "23 robustasa NaN ... Blue-Green \n", "24 robustasa 40 ... Blue-Green \n", "25 global opportunity fund 795 meters ... NaN \n", "26 cafe politico NaN ... Green \n", "27 cafe politico NaN ... None \n", "\n", " Category.Two.Defects Expiration \\\n", "0 2 June 26th, 2015 \n", "1 2 October 31st, 2018 \n", "2 0 April 29th, 2016 \n", "3 7 July 14th, 2015 \n", "4 3 June 26th, 2015 \n", "5 0 February 28th, 2013 \n", "6 0 May 15th, 2015 \n", "7 0 October 25th, 2018 \n", "8 0 August 17th, 2017 \n", "9 6 August 5th, 2015 \n", "10 1 June 26th, 2015 \n", "11 0 August 23rd, 2017 \n", "12 1 May 19th, 2015 \n", "13 7 July 14th, 2015 \n", "14 2 July 14th, 2015 \n", "15 0 April 29th, 2016 \n", "16 0 June 3rd, 2014 \n", "17 1 June 27th, 2015 \n", "18 2 June 27th, 2015 \n", "19 1 June 27th, 2015 \n", "20 1 May 19th, 2015 \n", "21 0 June 20th, 2014 \n", "22 0 February 28th, 2013 \n", "23 1 January 18th, 2017 \n", "24 0 January 18th, 2017 \n", "25 6 December 23rd, 2015 \n", "26 1 August 25th, 2015 \n", "27 9 August 25th, 2015 \n", "\n", " Certification.Body \\\n", "0 Uganda Coffee Development Authority \n", "1 Specialty Coffee Association \n", "2 Specialty Coffee Association \n", "3 Uganda Coffee Development Authority \n", "4 Uganda Coffee Development Authority \n", "5 Specialty Coffee Association \n", "6 Specialty Coffee Association \n", "7 Specialty Coffee Association \n", "8 Specialty Coffee Association \n", "9 Uganda Coffee Development Authority \n", "10 Uganda Coffee Development Authority \n", "11 Specialty Coffee Association \n", "12 Specialty Coffee Association \n", "13 Uganda Coffee Development Authority \n", "14 Uganda Coffee Development Authority \n", "15 Specialty Coffee Association \n", "16 Specialty Coffee Association \n", "17 Uganda Coffee Development Authority \n", "18 Uganda Coffee Development Authority \n", "19 Uganda Coffee Development Authority \n", "20 Specialty Coffee Association \n", "21 Specialty Coffee Association \n", "22 Specialty Coffee Association \n", "23 Specialty Coffee Association \n", "24 Specialty Coffee Association \n", "25 Specialty Coffee Association \n", "26 Specialty Coffee Association \n", "27 Specialty Coffee Association \n", "\n", " Certification.Address \\\n", "0 e36d0270932c3b657e96b7b0278dfd85dc0fe743 \n", "1 ff7c18ad303d4b603ac3f8cff7e611ffc735e720 \n", "2 ff7c18ad303d4b603ac3f8cff7e611ffc735e720 \n", "3 e36d0270932c3b657e96b7b0278dfd85dc0fe743 \n", "4 e36d0270932c3b657e96b7b0278dfd85dc0fe743 \n", "5 ff7c18ad303d4b603ac3f8cff7e611ffc735e720 \n", "6 ff7c18ad303d4b603ac3f8cff7e611ffc735e720 \n", "7 ff7c18ad303d4b603ac3f8cff7e611ffc735e720 \n", "8 ff7c18ad303d4b603ac3f8cff7e611ffc735e720 \n", "9 e36d0270932c3b657e96b7b0278dfd85dc0fe743 \n", "10 e36d0270932c3b657e96b7b0278dfd85dc0fe743 \n", "11 ff7c18ad303d4b603ac3f8cff7e611ffc735e720 \n", "12 ff7c18ad303d4b603ac3f8cff7e611ffc735e720 \n", "13 e36d0270932c3b657e96b7b0278dfd85dc0fe743 \n", "14 e36d0270932c3b657e96b7b0278dfd85dc0fe743 \n", "15 ff7c18ad303d4b603ac3f8cff7e611ffc735e720 \n", "16 ff7c18ad303d4b603ac3f8cff7e611ffc735e720 \n", "17 e36d0270932c3b657e96b7b0278dfd85dc0fe743 \n", "18 e36d0270932c3b657e96b7b0278dfd85dc0fe743 \n", "19 e36d0270932c3b657e96b7b0278dfd85dc0fe743 \n", "20 ff7c18ad303d4b603ac3f8cff7e611ffc735e720 \n", "21 ff7c18ad303d4b603ac3f8cff7e611ffc735e720 \n", "22 ff7c18ad303d4b603ac3f8cff7e611ffc735e720 \n", "23 ff7c18ad303d4b603ac3f8cff7e611ffc735e720 \n", "24 ff7c18ad303d4b603ac3f8cff7e611ffc735e720 \n", "25 ff7c18ad303d4b603ac3f8cff7e611ffc735e720 \n", "26 ff7c18ad303d4b603ac3f8cff7e611ffc735e720 \n", "27 ff7c18ad303d4b603ac3f8cff7e611ffc735e720 \n", "\n", " Certification.Contact unit_of_measurement \\\n", "0 03077a1c6bac60e6f514691634a7f6eb5c85aae8 m \n", "1 352d0cf7f3e9be14dad7df644ad65efc27605ae2 m \n", "2 352d0cf7f3e9be14dad7df644ad65efc27605ae2 m \n", "3 03077a1c6bac60e6f514691634a7f6eb5c85aae8 m \n", "4 03077a1c6bac60e6f514691634a7f6eb5c85aae8 m \n", "5 352d0cf7f3e9be14dad7df644ad65efc27605ae2 m \n", "6 352d0cf7f3e9be14dad7df644ad65efc27605ae2 m \n", "7 352d0cf7f3e9be14dad7df644ad65efc27605ae2 m \n", "8 352d0cf7f3e9be14dad7df644ad65efc27605ae2 m \n", "9 03077a1c6bac60e6f514691634a7f6eb5c85aae8 m \n", "10 03077a1c6bac60e6f514691634a7f6eb5c85aae8 m \n", "11 352d0cf7f3e9be14dad7df644ad65efc27605ae2 m \n", "12 352d0cf7f3e9be14dad7df644ad65efc27605ae2 m \n", "13 03077a1c6bac60e6f514691634a7f6eb5c85aae8 m \n", "14 03077a1c6bac60e6f514691634a7f6eb5c85aae8 m \n", "15 352d0cf7f3e9be14dad7df644ad65efc27605ae2 m \n", "16 352d0cf7f3e9be14dad7df644ad65efc27605ae2 m \n", "17 03077a1c6bac60e6f514691634a7f6eb5c85aae8 m \n", "18 03077a1c6bac60e6f514691634a7f6eb5c85aae8 m \n", "19 03077a1c6bac60e6f514691634a7f6eb5c85aae8 m \n", "20 352d0cf7f3e9be14dad7df644ad65efc27605ae2 m \n", "21 352d0cf7f3e9be14dad7df644ad65efc27605ae2 m \n", "22 352d0cf7f3e9be14dad7df644ad65efc27605ae2 m \n", "23 352d0cf7f3e9be14dad7df644ad65efc27605ae2 m \n", "24 352d0cf7f3e9be14dad7df644ad65efc27605ae2 m \n", "25 352d0cf7f3e9be14dad7df644ad65efc27605ae2 m \n", "26 352d0cf7f3e9be14dad7df644ad65efc27605ae2 m \n", "27 352d0cf7f3e9be14dad7df644ad65efc27605ae2 m \n", "\n", " altitude_low_meters altitude_high_meters altitude_mean_meters \n", "0 1488.0 1488.0 1488.0 \n", "1 3170.0 3170.0 3170.0 \n", "2 1000.0 1000.0 1000.0 \n", "3 1212.0 1212.0 1212.0 \n", "4 1200.0 1300.0 1250.0 \n", "5 3000.0 3000.0 3000.0 \n", "6 750.0 750.0 750.0 \n", "7 3140.0 3140.0 3140.0 \n", "8 1000.0 1000.0 1000.0 \n", "9 900.0 1300.0 1100.0 \n", "10 1095.0 1095.0 1095.0 \n", "11 1000.0 1000.0 1000.0 \n", "12 750.0 750.0 750.0 \n", "13 1367.0 1367.0 1367.0 \n", "14 1488.0 1488.0 1488.0 \n", "15 1000.0 1000.0 1000.0 \n", "16 750.0 750.0 750.0 \n", "17 1600.0 1600.0 1600.0 \n", "18 1745.0 1745.0 1745.0 \n", "19 1200.0 1200.0 1200.0 \n", "20 750.0 750.0 750.0 \n", "21 750.0 750.0 750.0 \n", "22 3000.0 3000.0 3000.0 \n", "23 NaN NaN NaN \n", "24 40.0 40.0 40.0 \n", "25 795.0 795.0 795.0 \n", "26 NaN NaN NaN \n", "27 NaN NaN NaN \n", "\n", "[28 rows x 44 columns]" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "pandas.read_csv(coffee_data_url)" ] }, { "cell_type": "markdown", "id": "87d70e6d", "metadata": {}, "source": [ "We'll use `pd` because that's the more common convention and so that we can type\n", "fewer characters throughout our code" ] }, { "cell_type": "code", "execution_count": 4, "id": "ec6b65d2", "metadata": {}, "outputs": [], "source": [ "import pandas as pd" ] }, { "cell_type": "markdown", "id": "81718fe8", "metadata": {}, "source": [ "## Examining DataFrames" ] }, { "cell_type": "code", "execution_count": 5, "id": "0a4e607f", "metadata": {}, "outputs": [], "source": [ "df = pd.read_csv(coffee_data_url,index_col=0)" ] }, { "cell_type": "markdown", "id": "f5360c3c", "metadata": {}, "source": [ "We can look at the first 5 rows with `head`" ] }, { "cell_type": "code", "execution_count": 6, "id": "f4e9bf3e", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
SpeciesOwnerCountry.of.OriginFarm.NameLot.NumberMillICO.NumberCompanyAltitudeRegion...ColorCategory.Two.DefectsExpirationCertification.BodyCertification.AddressCertification.Contactunit_of_measurementaltitude_low_metersaltitude_high_metersaltitude_mean_meters
1Robustaankole coffee producers coopUgandakyangundu cooperative societyNaNankole coffee producers0ankole coffee producers coop1488sheema south western...Green2June 26th, 2015Uganda Coffee Development Authoritye36d0270932c3b657e96b7b0278dfd85dc0fe74303077a1c6bac60e6f514691634a7f6eb5c85aae8m1488.01488.01488.0
2Robustanishant gurjerIndiasethuraman estate kaapi royale25sethuraman estate14/1148/2017/21kaapi royale3170chikmagalur karnataka indua...NaN2October 31st, 2018Specialty Coffee Associationff7c18ad303d4b603ac3f8cff7e611ffc735e720352d0cf7f3e9be14dad7df644ad65efc27605ae2m3170.03170.03170.0
3Robustaandrew hetzelIndiasethuraman estateNaNNaN0000sethuraman estate1000mchikmagalur...Green0April 29th, 2016Specialty Coffee Associationff7c18ad303d4b603ac3f8cff7e611ffc735e720352d0cf7f3e9be14dad7df644ad65efc27605ae2m1000.01000.01000.0
4RobustaugacofUgandaugacof project areaNaNugacof0ugacof ltd1212central...Green7July 14th, 2015Uganda Coffee Development Authoritye36d0270932c3b657e96b7b0278dfd85dc0fe74303077a1c6bac60e6f514691634a7f6eb5c85aae8m1212.01212.01212.0
5Robustakatuka development trust ltdUgandakatikamu capca farmers associationNaNkatuka development trust0katuka development trust ltd1200-1300luwero central region...Green3June 26th, 2015Uganda Coffee Development Authoritye36d0270932c3b657e96b7b0278dfd85dc0fe74303077a1c6bac60e6f514691634a7f6eb5c85aae8m1200.01300.01250.0
\n", "

5 rows × 43 columns

\n", "
" ], "text/plain": [ " Species Owner Country.of.Origin \\\n", "1 Robusta ankole coffee producers coop Uganda \n", "2 Robusta nishant gurjer India \n", "3 Robusta andrew hetzel India \n", "4 Robusta ugacof Uganda \n", "5 Robusta katuka development trust ltd Uganda \n", "\n", " Farm.Name Lot.Number Mill \\\n", "1 kyangundu cooperative society NaN ankole coffee producers \n", "2 sethuraman estate kaapi royale 25 sethuraman estate \n", "3 sethuraman estate NaN NaN \n", "4 ugacof project area NaN ugacof \n", "5 katikamu capca farmers association NaN katuka development trust \n", "\n", " ICO.Number Company Altitude \\\n", "1 0 ankole coffee producers coop 1488 \n", "2 14/1148/2017/21 kaapi royale 3170 \n", "3 0000 sethuraman estate 1000m \n", "4 0 ugacof ltd 1212 \n", "5 0 katuka development trust ltd 1200-1300 \n", "\n", " Region ... Color Category.Two.Defects \\\n", "1 sheema south western ... Green 2 \n", "2 chikmagalur karnataka indua ... NaN 2 \n", "3 chikmagalur ... Green 0 \n", "4 central ... Green 7 \n", "5 luwero central region ... Green 3 \n", "\n", " Expiration Certification.Body \\\n", "1 June 26th, 2015 Uganda Coffee Development Authority \n", "2 October 31st, 2018 Specialty Coffee Association \n", "3 April 29th, 2016 Specialty Coffee Association \n", "4 July 14th, 2015 Uganda Coffee Development Authority \n", "5 June 26th, 2015 Uganda Coffee Development Authority \n", "\n", " Certification.Address \\\n", "1 e36d0270932c3b657e96b7b0278dfd85dc0fe743 \n", "2 ff7c18ad303d4b603ac3f8cff7e611ffc735e720 \n", "3 ff7c18ad303d4b603ac3f8cff7e611ffc735e720 \n", "4 e36d0270932c3b657e96b7b0278dfd85dc0fe743 \n", "5 e36d0270932c3b657e96b7b0278dfd85dc0fe743 \n", "\n", " Certification.Contact unit_of_measurement \\\n", "1 03077a1c6bac60e6f514691634a7f6eb5c85aae8 m \n", "2 352d0cf7f3e9be14dad7df644ad65efc27605ae2 m \n", "3 352d0cf7f3e9be14dad7df644ad65efc27605ae2 m \n", "4 03077a1c6bac60e6f514691634a7f6eb5c85aae8 m \n", "5 03077a1c6bac60e6f514691634a7f6eb5c85aae8 m \n", "\n", " altitude_low_meters altitude_high_meters altitude_mean_meters \n", "1 1488.0 1488.0 1488.0 \n", "2 3170.0 3170.0 3170.0 \n", "3 1000.0 1000.0 1000.0 \n", "4 1212.0 1212.0 1212.0 \n", "5 1200.0 1300.0 1250.0 \n", "\n", "[5 rows x 43 columns]" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df.head()" ] }, { "cell_type": "markdown", "id": "3577fb2f", "metadata": {}, "source": [ "Using help, we can see that that head takes one parameter and has a default value\n", "of 5, which is why we got 5 rows, but we can get 2 instead" ] }, { "cell_type": "code", "execution_count": 7, "id": "653aaacf", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
SpeciesOwnerCountry.of.OriginFarm.NameLot.NumberMillICO.NumberCompanyAltitudeRegion...ColorCategory.Two.DefectsExpirationCertification.BodyCertification.AddressCertification.Contactunit_of_measurementaltitude_low_metersaltitude_high_metersaltitude_mean_meters
1Robustaankole coffee producers coopUgandakyangundu cooperative societyNaNankole coffee producers0ankole coffee producers coop1488sheema south western...Green2June 26th, 2015Uganda Coffee Development Authoritye36d0270932c3b657e96b7b0278dfd85dc0fe74303077a1c6bac60e6f514691634a7f6eb5c85aae8m1488.01488.01488.0
2Robustanishant gurjerIndiasethuraman estate kaapi royale25sethuraman estate14/1148/2017/21kaapi royale3170chikmagalur karnataka indua...NaN2October 31st, 2018Specialty Coffee Associationff7c18ad303d4b603ac3f8cff7e611ffc735e720352d0cf7f3e9be14dad7df644ad65efc27605ae2m3170.03170.03170.0
\n", "

2 rows × 43 columns

\n", "
" ], "text/plain": [ " Species Owner Country.of.Origin \\\n", "1 Robusta ankole coffee producers coop Uganda \n", "2 Robusta nishant gurjer India \n", "\n", " Farm.Name Lot.Number Mill \\\n", "1 kyangundu cooperative society NaN ankole coffee producers \n", "2 sethuraman estate kaapi royale 25 sethuraman estate \n", "\n", " ICO.Number Company Altitude \\\n", "1 0 ankole coffee producers coop 1488 \n", "2 14/1148/2017/21 kaapi royale 3170 \n", "\n", " Region ... Color Category.Two.Defects \\\n", "1 sheema south western ... Green 2 \n", "2 chikmagalur karnataka indua ... NaN 2 \n", "\n", " Expiration Certification.Body \\\n", "1 June 26th, 2015 Uganda Coffee Development Authority \n", "2 October 31st, 2018 Specialty Coffee Association \n", "\n", " Certification.Address \\\n", "1 e36d0270932c3b657e96b7b0278dfd85dc0fe743 \n", "2 ff7c18ad303d4b603ac3f8cff7e611ffc735e720 \n", "\n", " Certification.Contact unit_of_measurement \\\n", "1 03077a1c6bac60e6f514691634a7f6eb5c85aae8 m \n", "2 352d0cf7f3e9be14dad7df644ad65efc27605ae2 m \n", "\n", " altitude_low_meters altitude_high_meters altitude_mean_meters \n", "1 1488.0 1488.0 1488.0 \n", "2 3170.0 3170.0 3170.0 \n", "\n", "[2 rows x 43 columns]" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df.head(2)" ] }, { "cell_type": "markdown", "id": "0d87181d", "metadata": {}, "source": [ "We can look at the last rows with `tail`" ] }, { "cell_type": "code", "execution_count": 8, "id": "6fee1a91", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
SpeciesOwnerCountry.of.OriginFarm.NameLot.NumberMillICO.NumberCompanyAltitudeRegion...ColorCategory.Two.DefectsExpirationCertification.BodyCertification.AddressCertification.Contactunit_of_measurementaltitude_low_metersaltitude_high_metersaltitude_mean_meters
26Robustajames mooreUnited Statesfazenda cazengoNaNcafe cazengoNaNglobal opportunity fund795 meterskwanza norte province, angola...NaN6December 23rd, 2015Specialty Coffee Associationff7c18ad303d4b603ac3f8cff7e611ffc735e720352d0cf7f3e9be14dad7df644ad65efc27605ae2m795.0795.0795.0
27Robustacafe politicoIndiaNaNNaNNaN14-1118-2014-0087cafe politicoNaNNaN...Green1August 25th, 2015Specialty Coffee Associationff7c18ad303d4b603ac3f8cff7e611ffc735e720352d0cf7f3e9be14dad7df644ad65efc27605ae2mNaNNaNNaN
28Robustacafe politicoVietnamNaNNaNNaNNaNcafe politicoNaNNaN...None9August 25th, 2015Specialty Coffee Associationff7c18ad303d4b603ac3f8cff7e611ffc735e720352d0cf7f3e9be14dad7df644ad65efc27605ae2mNaNNaNNaN
\n", "

3 rows × 43 columns

\n", "
" ], "text/plain": [ " Species Owner Country.of.Origin Farm.Name Lot.Number \\\n", "26 Robusta james moore United States fazenda cazengo NaN \n", "27 Robusta cafe politico India NaN NaN \n", "28 Robusta cafe politico Vietnam NaN NaN \n", "\n", " Mill ICO.Number Company Altitude \\\n", "26 cafe cazengo NaN global opportunity fund 795 meters \n", "27 NaN 14-1118-2014-0087 cafe politico NaN \n", "28 NaN NaN cafe politico NaN \n", "\n", " Region ... Color Category.Two.Defects \\\n", "26 kwanza norte province, angola ... NaN 6 \n", "27 NaN ... Green 1 \n", "28 NaN ... None 9 \n", "\n", " Expiration Certification.Body \\\n", "26 December 23rd, 2015 Specialty Coffee Association \n", "27 August 25th, 2015 Specialty Coffee Association \n", "28 August 25th, 2015 Specialty Coffee Association \n", "\n", " Certification.Address \\\n", "26 ff7c18ad303d4b603ac3f8cff7e611ffc735e720 \n", "27 ff7c18ad303d4b603ac3f8cff7e611ffc735e720 \n", "28 ff7c18ad303d4b603ac3f8cff7e611ffc735e720 \n", "\n", " Certification.Contact unit_of_measurement \\\n", "26 352d0cf7f3e9be14dad7df644ad65efc27605ae2 m \n", "27 352d0cf7f3e9be14dad7df644ad65efc27605ae2 m \n", "28 352d0cf7f3e9be14dad7df644ad65efc27605ae2 m \n", "\n", " altitude_low_meters altitude_high_meters altitude_mean_meters \n", "26 795.0 795.0 795.0 \n", "27 NaN NaN NaN \n", "28 NaN NaN NaN \n", "\n", "[3 rows x 43 columns]" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df.tail(3)" ] }, { "cell_type": "markdown", "id": "b6da3818", "metadata": {}, "source": [ "I told you this was a DataFrame, but we can check with type." ] }, { "cell_type": "code", "execution_count": 9, "id": "b58c55c7", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "pandas.core.frame.DataFrame" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "type(df)" ] }, { "cell_type": "markdown", "id": "a0b8dd28", "metadata": {}, "source": [ "We can also exmaine its parts. It consists of several; first the column headings" ] }, { "cell_type": "code", "execution_count": 10, "id": "5c43da7a", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "Index(['Species', 'Owner', 'Country.of.Origin', 'Farm.Name', 'Lot.Number',\n", " 'Mill', 'ICO.Number', 'Company', 'Altitude', 'Region', 'Producer',\n", " 'Number.of.Bags', 'Bag.Weight', 'In.Country.Partner', 'Harvest.Year',\n", " 'Grading.Date', 'Owner.1', 'Variety', 'Processing.Method',\n", " 'Fragrance...Aroma', 'Flavor', 'Aftertaste', 'Salt...Acid',\n", " 'Bitter...Sweet', 'Mouthfeel', 'Uniform.Cup', 'Clean.Cup', 'Balance',\n", " 'Cupper.Points', 'Total.Cup.Points', 'Moisture', 'Category.One.Defects',\n", " 'Quakers', 'Color', 'Category.Two.Defects', 'Expiration',\n", " 'Certification.Body', 'Certification.Address', 'Certification.Contact',\n", " 'unit_of_measurement', 'altitude_low_meters', 'altitude_high_meters',\n", " 'altitude_mean_meters'],\n", " dtype='object')" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df.columns" ] }, { "cell_type": "markdown", "id": "59e3f427", "metadata": {}, "source": [ "These are a special type called Index" ] }, { "cell_type": "code", "execution_count": 11, "id": "30523481", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "pandas.core.indexes.base.Index" ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "type(df.columns)" ] }, { "cell_type": "markdown", "id": "4e4242b8", "metadata": {}, "source": [ "It also has an index" ] }, { "cell_type": "code", "execution_count": 12, "id": "5aa20902", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "Int64Index([ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,\n", " 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28],\n", " dtype='int64')" ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df.index" ] }, { "cell_type": "markdown", "id": "b095d1f4", "metadata": {}, "source": [ "and values" ] }, { "cell_type": "code", "execution_count": 13, "id": "fb4cce91", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array([['Robusta', 'ankole coffee producers coop', 'Uganda', ..., 1488.0,\n", " 1488.0, 1488.0],\n", " ['Robusta', 'nishant gurjer', 'India', ..., 3170.0, 3170.0,\n", " 3170.0],\n", " ['Robusta', 'andrew hetzel', 'India', ..., 1000.0, 1000.0, 1000.0],\n", " ...,\n", " ['Robusta', 'james moore', 'United States', ..., 795.0, 795.0,\n", " 795.0],\n", " ['Robusta', 'cafe politico', 'India', ..., nan, nan, nan],\n", " ['Robusta', 'cafe politico', 'Vietnam', ..., nan, nan, nan]],\n", " dtype=object)" ] }, "execution_count": 13, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df.values" ] }, { "cell_type": "markdown", "id": "9f09a3b2", "metadata": {}, "source": [ "it also knows its own shape" ] }, { "cell_type": "code", "execution_count": 14, "id": "157c7e9f", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "(28, 43)" ] }, "execution_count": 14, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df.shape" ] }, { "cell_type": "markdown", "id": "de043cbf", "metadata": {}, "source": [ "we can use builtin fucntions on our DataFrame too not just its own methods and\n", "attributes." ] }, { "cell_type": "code", "execution_count": 15, "id": "4579656f", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "28" ] }, "execution_count": 15, "metadata": {}, "output_type": "execute_result" } ], "source": [ "len(df)" ] }, { "cell_type": "markdown", "id": "24389b27", "metadata": {}, "source": [ "Why does `len` turn green?\n", "it's a python reserve word\n", "\n", "## Building a Data Frame programmatically\n", "\n", "One way to build a data frame is from a dictionary:" ] }, { "cell_type": "code", "execution_count": 16, "id": "7208707c", "metadata": {}, "outputs": [], "source": [ "people = {'names':['Sarah','Connor','Kenza'],\n", " 'username':['brownsarahm','sudoPsych','kbdlh']}" ] }, { "cell_type": "code", "execution_count": 17, "id": "a33e8ef8", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'names': ['Sarah', 'Connor', 'Kenza'],\n", " 'username': ['brownsarahm', 'sudoPsych', 'kbdlh']}" ] }, "execution_count": 17, "metadata": {}, "output_type": "execute_result" } ], "source": [ "people" ] }, { "cell_type": "code", "execution_count": 18, "id": "8fed0bd9", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "dict" ] }, "execution_count": 18, "metadata": {}, "output_type": "execute_result" } ], "source": [ "type(people)" ] }, { "cell_type": "code", "execution_count": 19, "id": "74918dc7", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
namesusername
0Sarahbrownsarahm
1ConnorsudoPsych
2Kenzakbdlh
\n", "
" ], "text/plain": [ " names username\n", "0 Sarah brownsarahm\n", "1 Connor sudoPsych\n", "2 Kenza kbdlh" ] }, "execution_count": 19, "metadata": {}, "output_type": "execute_result" } ], "source": [ "people_df = pd.DataFrame(people)\n", "people_df" ] }, { "cell_type": "code", "execution_count": 20, "id": "20e327c4", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "list" ] }, "execution_count": 20, "metadata": {}, "output_type": "execute_result" } ], "source": [ "type(people['names'])" ] }, { "cell_type": "code", "execution_count": 21, "id": "4f326294", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "dict" ] }, "execution_count": 21, "metadata": {}, "output_type": "execute_result" } ], "source": [ "type(people)" ] }, { "cell_type": "code", "execution_count": 22, "id": "2e710357", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "set" ] }, "execution_count": 22, "metadata": {}, "output_type": "execute_result" } ], "source": [ "type({4,5,5})" ] }, { "cell_type": "code", "execution_count": 23, "id": "991f7d35", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{4, 5}" ] }, "execution_count": 23, "metadata": {}, "output_type": "execute_result" } ], "source": [ "{4,5,5}" ] }, { "cell_type": "code", "execution_count": 24, "id": "5be00336", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "['Sarah', 'Connor', 'Kenza']" ] }, "execution_count": 24, "metadata": {}, "output_type": "execute_result" } ], "source": [ "people['names']" ] }, { "cell_type": "code", "execution_count": 25, "id": "c3951727", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "set" ] }, "execution_count": 25, "metadata": {}, "output_type": "execute_result" } ], "source": [ "type(set(people['names']))" ] }, { "cell_type": "code", "execution_count": 26, "id": "5810c95a", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "set" ] }, "execution_count": 26, "metadata": {}, "output_type": "execute_result" } ], "source": [ "unique_people = set(people['names'])\n", "type(unique_people)" ] }, { "cell_type": "code", "execution_count": 27, "id": "1522bad5", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "Index(['Species', 'Owner', 'Country.of.Origin', 'Farm.Name', 'Lot.Number',\n", " 'Mill', 'ICO.Number', 'Company', 'Altitude', 'Region', 'Producer',\n", " 'Number.of.Bags', 'Bag.Weight', 'In.Country.Partner', 'Harvest.Year',\n", " 'Grading.Date', 'Owner.1', 'Variety', 'Processing.Method',\n", " 'Fragrance...Aroma', 'Flavor', 'Aftertaste', 'Salt...Acid',\n", " 'Bitter...Sweet', 'Mouthfeel', 'Uniform.Cup', 'Clean.Cup', 'Balance',\n", " 'Cupper.Points', 'Total.Cup.Points', 'Moisture', 'Category.One.Defects',\n", " 'Quakers', 'Color', 'Category.Two.Defects', 'Expiration',\n", " 'Certification.Body', 'Certification.Address', 'Certification.Contact',\n", " 'unit_of_measurement', 'altitude_low_meters', 'altitude_high_meters',\n", " 'altitude_mean_meters'],\n", " dtype='object')" ] }, "execution_count": 27, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df.columns" ] }, { "cell_type": "code", "execution_count": 28, "id": "942e1dc8", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "['Species']\n", "['Owner']\n", "['Country', 'of', 'Origin']\n", "['Farm', 'Name']\n", "['Lot', 'Number']\n", "['Mill']\n", "['ICO', 'Number']\n", "['Company']\n", "['Altitude']\n", "['Region']\n", "['Producer']\n", "['Number', 'of', 'Bags']\n", "['Bag', 'Weight']\n", "['In', 'Country', 'Partner']\n", "['Harvest', 'Year']\n", "['Grading', 'Date']\n", "['Owner', '1']\n", "['Variety']\n", "['Processing', 'Method']\n", "['Fragrance', '', '', 'Aroma']\n", "['Flavor']\n", "['Aftertaste']\n", "['Salt', '', '', 'Acid']\n", "['Bitter', '', '', 'Sweet']\n", "['Mouthfeel']\n", "['Uniform', 'Cup']\n", "['Clean', 'Cup']\n", "['Balance']\n", "['Cupper', 'Points']\n", "['Total', 'Cup', 'Points']\n", "['Moisture']\n", "['Category', 'One', 'Defects']\n", "['Quakers']\n", "['Color']\n", "['Category', 'Two', 'Defects']\n", "['Expiration']\n", "['Certification', 'Body']\n", "['Certification', 'Address']\n", "['Certification', 'Contact']\n", "['unit_of_measurement']\n", "['altitude_low_meters']\n", "['altitude_high_meters']\n", "['altitude_mean_meters']\n" ] } ], "source": [ "for col in df.columns:\n", " print(col.split('.'))" ] }, { "cell_type": "code", "execution_count": 29, "id": "1d0c5242", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "names : ['Sarah', 'Connor', 'Kenza']\n", "username : ['brownsarahm', 'sudoPsych', 'kbdlh']\n" ] } ], "source": [ "for key,value in people.items():\n", " print(key,':',value)" ] }, { "cell_type": "code", "execution_count": 30, "id": "47afd120", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "1 ankole coffee producers coop\n", "2 nishant gurjer\n", "3 andrew hetzel\n", "4 ugacof\n", "5 katuka development trust ltd\n", "6 andrew hetzel\n", "7 andrew hetzel\n", "8 nishant gurjer\n", "9 nishant gurjer\n", "10 ugacof\n", "11 ugacof\n", "12 nishant gurjer\n", "13 andrew hetzel\n", "14 kasozi coffee farmers association\n", "15 ankole coffee producers coop\n", "16 andrew hetzel\n", "17 andrew hetzel\n", "18 kawacom uganda ltd\n", "19 nitubaasa ltd\n", "20 mannya coffee project\n", "21 andrew hetzel\n", "22 andrew hetzel\n", "23 andrew hetzel\n", "24 luis robles\n", "25 luis robles\n", "26 james moore\n", "27 cafe politico\n", "28 cafe politico\n", "Name: Owner, dtype: object" ] }, "execution_count": 30, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df['Owner']" ] }, { "cell_type": "code", "execution_count": 31, "id": "95a38b39", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "1 ankole coffee producers coop\n", "2 nishant gurjer\n", "3 andrew hetzel\n", "4 ugacof\n", "5 katuka development trust ltd\n", "6 andrew hetzel\n", "7 andrew hetzel\n", "8 nishant gurjer\n", "9 nishant gurjer\n", "10 ugacof\n", "11 ugacof\n", "12 nishant gurjer\n", "13 andrew hetzel\n", "14 kasozi coffee farmers association\n", "15 ankole coffee producers coop\n", "16 andrew hetzel\n", "17 andrew hetzel\n", "18 kawacom uganda ltd\n", "19 nitubaasa ltd\n", "20 mannya coffee project\n", "21 andrew hetzel\n", "22 andrew hetzel\n", "23 andrew hetzel\n", "24 luis robles\n", "25 luis robles\n", "26 james moore\n", "27 cafe politico\n", "28 cafe politico\n", "Name: Owner, dtype: object" ] }, "execution_count": 31, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df.Owner" ] }, { "cell_type": "code", "execution_count": 32, "id": "d6f9d46a", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
SpeciesOwnerCountry.of.OriginFarm.NameLot.NumberMillICO.NumberCompanyAltitudeRegion...ColorCategory.Two.DefectsExpirationCertification.BodyCertification.AddressCertification.Contactunit_of_measurementaltitude_low_metersaltitude_high_metersaltitude_mean_meters
1Robustaankole coffee producers coopUgandakyangundu cooperative societyNaNankole coffee producers0ankole coffee producers coop1488sheema south western...Green2June 26th, 2015Uganda Coffee Development Authoritye36d0270932c3b657e96b7b0278dfd85dc0fe74303077a1c6bac60e6f514691634a7f6eb5c85aae8m1488.01488.01488.0
2Robustanishant gurjerIndiasethuraman estate kaapi royale25sethuraman estate14/1148/2017/21kaapi royale3170chikmagalur karnataka indua...NaN2October 31st, 2018Specialty Coffee Associationff7c18ad303d4b603ac3f8cff7e611ffc735e720352d0cf7f3e9be14dad7df644ad65efc27605ae2m3170.03170.03170.0
3Robustaandrew hetzelIndiasethuraman estateNaNNaN0000sethuraman estate1000mchikmagalur...Green0April 29th, 2016Specialty Coffee Associationff7c18ad303d4b603ac3f8cff7e611ffc735e720352d0cf7f3e9be14dad7df644ad65efc27605ae2m1000.01000.01000.0
4RobustaugacofUgandaugacof project areaNaNugacof0ugacof ltd1212central...Green7July 14th, 2015Uganda Coffee Development Authoritye36d0270932c3b657e96b7b0278dfd85dc0fe74303077a1c6bac60e6f514691634a7f6eb5c85aae8m1212.01212.01212.0
5Robustakatuka development trust ltdUgandakatikamu capca farmers associationNaNkatuka development trust0katuka development trust ltd1200-1300luwero central region...Green3June 26th, 2015Uganda Coffee Development Authoritye36d0270932c3b657e96b7b0278dfd85dc0fe74303077a1c6bac60e6f514691634a7f6eb5c85aae8m1200.01300.01250.0
6Robustaandrew hetzelIndiaNaNNaN(self)NaNcafemakers, llc3000'chikmagalur...Green0February 28th, 2013Specialty Coffee Associationff7c18ad303d4b603ac3f8cff7e611ffc735e720352d0cf7f3e9be14dad7df644ad65efc27605ae2m3000.03000.03000.0
7Robustaandrew hetzelIndiasethuraman estatesNaNNaNNaNcafemakers750mchikmagalur...Green0May 15th, 2015Specialty Coffee Associationff7c18ad303d4b603ac3f8cff7e611ffc735e720352d0cf7f3e9be14dad7df644ad65efc27605ae2m750.0750.0750.0
8Robustanishant gurjerIndiasethuraman estate kaapi royale7sethuraman estate14/1148/2017/18kaapi royale3140chikmagalur karnataka india...Bluish-Green0October 25th, 2018Specialty Coffee Associationff7c18ad303d4b603ac3f8cff7e611ffc735e720352d0cf7f3e9be14dad7df644ad65efc27605ae2m3140.03140.03140.0
9Robustanishant gurjerIndiasethuraman estateRKRsethuraman estate14/1148/2016/17kaapi royale1000chikmagalur karnataka...Green0August 17th, 2017Specialty Coffee Associationff7c18ad303d4b603ac3f8cff7e611ffc735e720352d0cf7f3e9be14dad7df644ad65efc27605ae2m1000.01000.01000.0
10RobustaugacofUgandaishakaNaNnsubuga umar0ugacof ltd900-1300western...Green6August 5th, 2015Uganda Coffee Development Authoritye36d0270932c3b657e96b7b0278dfd85dc0fe74303077a1c6bac60e6f514691634a7f6eb5c85aae8m900.01300.01100.0
11RobustaugacofUgandaugacof project areaNaNugacof0ugacof ltd1095iganga namadrope eastern...Green1June 26th, 2015Uganda Coffee Development Authoritye36d0270932c3b657e96b7b0278dfd85dc0fe74303077a1c6bac60e6f514691634a7f6eb5c85aae8m1095.01095.01095.0
12Robustanishant gurjerIndiasethuraman estate kaapi royaleRC ABsethuraman estate14/1148/2016/12kaapi royale1000chikmagalur karnataka...Green0August 23rd, 2017Specialty Coffee Associationff7c18ad303d4b603ac3f8cff7e611ffc735e720352d0cf7f3e9be14dad7df644ad65efc27605ae2m1000.01000.01000.0
13Robustaandrew hetzelIndiasethuraman estatesNaNNaNNaNcafemakers750mchikmagalur...Green1May 19th, 2015Specialty Coffee Associationff7c18ad303d4b603ac3f8cff7e611ffc735e720352d0cf7f3e9be14dad7df644ad65efc27605ae2m750.0750.0750.0
14Robustakasozi coffee farmers associationUgandakasozi coffee farmersNaNNaN0kasozi coffee farmers association1367eastern...Green7July 14th, 2015Uganda Coffee Development Authoritye36d0270932c3b657e96b7b0278dfd85dc0fe74303077a1c6bac60e6f514691634a7f6eb5c85aae8m1367.01367.01367.0
15Robustaankole coffee producers coopUgandakyangundu coop societyNaNankole coffee producers coop union ltd0ankole coffee producers coop1488south western...Green2July 14th, 2015Uganda Coffee Development Authoritye36d0270932c3b657e96b7b0278dfd85dc0fe74303077a1c6bac60e6f514691634a7f6eb5c85aae8m1488.01488.01488.0
16Robustaandrew hetzelIndiasethuraman estateNaNNaN0000sethuraman estate1000mchikmagalur...Green0April 29th, 2016Specialty Coffee Associationff7c18ad303d4b603ac3f8cff7e611ffc735e720352d0cf7f3e9be14dad7df644ad65efc27605ae2m1000.01000.01000.0
17Robustaandrew hetzelIndiasethuraman estatesNaNsethuraman estatesNaNcafemakers, llc750mchikmagalur...Blue-Green0June 3rd, 2014Specialty Coffee Associationff7c18ad303d4b603ac3f8cff7e611ffc735e720352d0cf7f3e9be14dad7df644ad65efc27605ae2m750.0750.0750.0
18Robustakawacom uganda ltdUgandabushenyiNaNkawacom0kawacom uganda ltd1600western...Green1June 27th, 2015Uganda Coffee Development Authoritye36d0270932c3b657e96b7b0278dfd85dc0fe74303077a1c6bac60e6f514691634a7f6eb5c85aae8m1600.01600.01600.0
19Robustanitubaasa ltdUgandakigezi coffee farmers associationNaNnitubaasa0nitubaasa ltd1745western...Green2June 27th, 2015Uganda Coffee Development Authoritye36d0270932c3b657e96b7b0278dfd85dc0fe74303077a1c6bac60e6f514691634a7f6eb5c85aae8m1745.01745.01745.0
20Robustamannya coffee projectUgandamannya coffee projectNaNmannya coffee project0mannya coffee project1200southern...Green1June 27th, 2015Uganda Coffee Development Authoritye36d0270932c3b657e96b7b0278dfd85dc0fe74303077a1c6bac60e6f514691634a7f6eb5c85aae8m1200.01200.01200.0
21Robustaandrew hetzelIndiasethuraman estatesNaNNaNNaNcafemakers750mchikmagalur...Bluish-Green1May 19th, 2015Specialty Coffee Associationff7c18ad303d4b603ac3f8cff7e611ffc735e720352d0cf7f3e9be14dad7df644ad65efc27605ae2m750.0750.0750.0
22Robustaandrew hetzelIndiasethuraman estatesNaNsethuraman estatesNaNcafemakers, llc750mchikmagalur...Green0June 20th, 2014Specialty Coffee Associationff7c18ad303d4b603ac3f8cff7e611ffc735e720352d0cf7f3e9be14dad7df644ad65efc27605ae2m750.0750.0750.0
23Robustaandrew hetzelUnited Statessethuraman estatesNaNsethuraman estatesNaNcafemakers, llc3000'chikmagalur...Green0February 28th, 2013Specialty Coffee Associationff7c18ad303d4b603ac3f8cff7e611ffc735e720352d0cf7f3e9be14dad7df644ad65efc27605ae2m3000.03000.03000.0
24Robustaluis roblesEcuadorrobustasaLavado 1our own labNaNrobustasaNaNsan juan, playas...Blue-Green1January 18th, 2017Specialty Coffee Associationff7c18ad303d4b603ac3f8cff7e611ffc735e720352d0cf7f3e9be14dad7df644ad65efc27605ae2mNaNNaNNaN
25Robustaluis roblesEcuadorrobustasaLavado 3own laboratoryNaNrobustasa40san juan, playas...Blue-Green0January 18th, 2017Specialty Coffee Associationff7c18ad303d4b603ac3f8cff7e611ffc735e720352d0cf7f3e9be14dad7df644ad65efc27605ae2m40.040.040.0
26Robustajames mooreUnited Statesfazenda cazengoNaNcafe cazengoNaNglobal opportunity fund795 meterskwanza norte province, angola...NaN6December 23rd, 2015Specialty Coffee Associationff7c18ad303d4b603ac3f8cff7e611ffc735e720352d0cf7f3e9be14dad7df644ad65efc27605ae2m795.0795.0795.0
27Robustacafe politicoIndiaNaNNaNNaN14-1118-2014-0087cafe politicoNaNNaN...Green1August 25th, 2015Specialty Coffee Associationff7c18ad303d4b603ac3f8cff7e611ffc735e720352d0cf7f3e9be14dad7df644ad65efc27605ae2mNaNNaNNaN
28Robustacafe politicoVietnamNaNNaNNaNNaNcafe politicoNaNNaN...None9August 25th, 2015Specialty Coffee Associationff7c18ad303d4b603ac3f8cff7e611ffc735e720352d0cf7f3e9be14dad7df644ad65efc27605ae2mNaNNaNNaN
\n", "

28 rows × 43 columns

\n", "
" ], "text/plain": [ " Species Owner Country.of.Origin \\\n", "1 Robusta ankole coffee producers coop Uganda \n", "2 Robusta nishant gurjer India \n", "3 Robusta andrew hetzel India \n", "4 Robusta ugacof Uganda \n", "5 Robusta katuka development trust ltd Uganda \n", "6 Robusta andrew hetzel India \n", "7 Robusta andrew hetzel India \n", "8 Robusta nishant gurjer India \n", "9 Robusta nishant gurjer India \n", "10 Robusta ugacof Uganda \n", "11 Robusta ugacof Uganda \n", "12 Robusta nishant gurjer India \n", "13 Robusta andrew hetzel India \n", "14 Robusta kasozi coffee farmers association Uganda \n", "15 Robusta ankole coffee producers coop Uganda \n", "16 Robusta andrew hetzel India \n", "17 Robusta andrew hetzel India \n", "18 Robusta kawacom uganda ltd Uganda \n", "19 Robusta nitubaasa ltd Uganda \n", "20 Robusta mannya coffee project Uganda \n", "21 Robusta andrew hetzel India \n", "22 Robusta andrew hetzel India \n", "23 Robusta andrew hetzel United States \n", "24 Robusta luis robles Ecuador \n", "25 Robusta luis robles Ecuador \n", "26 Robusta james moore United States \n", "27 Robusta cafe politico India \n", "28 Robusta cafe politico Vietnam \n", "\n", " Farm.Name Lot.Number \\\n", "1 kyangundu cooperative society NaN \n", "2 sethuraman estate kaapi royale 25 \n", "3 sethuraman estate NaN \n", "4 ugacof project area NaN \n", "5 katikamu capca farmers association NaN \n", "6 NaN NaN \n", "7 sethuraman estates NaN \n", "8 sethuraman estate kaapi royale 7 \n", "9 sethuraman estate RKR \n", "10 ishaka NaN \n", "11 ugacof project area NaN \n", "12 sethuraman estate kaapi royale RC AB \n", "13 sethuraman estates NaN \n", "14 kasozi coffee farmers NaN \n", "15 kyangundu coop society NaN \n", "16 sethuraman estate NaN \n", "17 sethuraman estates NaN \n", "18 bushenyi NaN \n", "19 kigezi coffee farmers association NaN \n", "20 mannya coffee project NaN \n", "21 sethuraman estates NaN \n", "22 sethuraman estates NaN \n", "23 sethuraman estates NaN \n", "24 robustasa Lavado 1 \n", "25 robustasa Lavado 3 \n", "26 fazenda cazengo NaN \n", "27 NaN NaN \n", "28 NaN NaN \n", "\n", " Mill ICO.Number \\\n", "1 ankole coffee producers 0 \n", "2 sethuraman estate 14/1148/2017/21 \n", "3 NaN 0000 \n", "4 ugacof 0 \n", "5 katuka development trust 0 \n", "6 (self) NaN \n", "7 NaN NaN \n", "8 sethuraman estate 14/1148/2017/18 \n", "9 sethuraman estate 14/1148/2016/17 \n", "10 nsubuga umar 0 \n", "11 ugacof 0 \n", "12 sethuraman estate 14/1148/2016/12 \n", "13 NaN NaN \n", "14 NaN 0 \n", "15 ankole coffee producers coop union ltd 0 \n", "16 NaN 0000 \n", "17 sethuraman estates NaN \n", "18 kawacom 0 \n", "19 nitubaasa 0 \n", "20 mannya coffee project 0 \n", "21 NaN NaN \n", "22 sethuraman estates NaN \n", "23 sethuraman estates NaN \n", "24 our own lab NaN \n", "25 own laboratory NaN \n", "26 cafe cazengo NaN \n", "27 NaN 14-1118-2014-0087 \n", "28 NaN NaN \n", "\n", " Company Altitude \\\n", "1 ankole coffee producers coop 1488 \n", "2 kaapi royale 3170 \n", "3 sethuraman estate 1000m \n", "4 ugacof ltd 1212 \n", "5 katuka development trust ltd 1200-1300 \n", "6 cafemakers, llc 3000' \n", "7 cafemakers 750m \n", "8 kaapi royale 3140 \n", "9 kaapi royale 1000 \n", "10 ugacof ltd 900-1300 \n", "11 ugacof ltd 1095 \n", "12 kaapi royale 1000 \n", "13 cafemakers 750m \n", "14 kasozi coffee farmers association 1367 \n", "15 ankole coffee producers coop 1488 \n", "16 sethuraman estate 1000m \n", "17 cafemakers, llc 750m \n", "18 kawacom uganda ltd 1600 \n", "19 nitubaasa ltd 1745 \n", "20 mannya coffee project 1200 \n", "21 cafemakers 750m \n", "22 cafemakers, llc 750m \n", "23 cafemakers, llc 3000' \n", "24 robustasa NaN \n", "25 robustasa 40 \n", "26 global opportunity fund 795 meters \n", "27 cafe politico NaN \n", "28 cafe politico NaN \n", "\n", " Region ... Color Category.Two.Defects \\\n", "1 sheema south western ... Green 2 \n", "2 chikmagalur karnataka indua ... NaN 2 \n", "3 chikmagalur ... Green 0 \n", "4 central ... Green 7 \n", "5 luwero central region ... Green 3 \n", "6 chikmagalur ... Green 0 \n", "7 chikmagalur ... Green 0 \n", "8 chikmagalur karnataka india ... Bluish-Green 0 \n", "9 chikmagalur karnataka ... Green 0 \n", "10 western ... Green 6 \n", "11 iganga namadrope eastern ... Green 1 \n", "12 chikmagalur karnataka ... Green 0 \n", "13 chikmagalur ... Green 1 \n", "14 eastern ... Green 7 \n", "15 south western ... Green 2 \n", "16 chikmagalur ... Green 0 \n", "17 chikmagalur ... Blue-Green 0 \n", "18 western ... Green 1 \n", "19 western ... Green 2 \n", "20 southern ... Green 1 \n", "21 chikmagalur ... Bluish-Green 1 \n", "22 chikmagalur ... Green 0 \n", "23 chikmagalur ... Green 0 \n", "24 san juan, playas ... Blue-Green 1 \n", "25 san juan, playas ... Blue-Green 0 \n", "26 kwanza norte province, angola ... NaN 6 \n", "27 NaN ... Green 1 \n", "28 NaN ... None 9 \n", "\n", " Expiration Certification.Body \\\n", "1 June 26th, 2015 Uganda Coffee Development Authority \n", "2 October 31st, 2018 Specialty Coffee Association \n", "3 April 29th, 2016 Specialty Coffee Association \n", "4 July 14th, 2015 Uganda Coffee Development Authority \n", "5 June 26th, 2015 Uganda Coffee Development Authority \n", "6 February 28th, 2013 Specialty Coffee Association \n", "7 May 15th, 2015 Specialty Coffee Association \n", "8 October 25th, 2018 Specialty Coffee Association \n", "9 August 17th, 2017 Specialty Coffee Association \n", "10 August 5th, 2015 Uganda Coffee Development Authority \n", "11 June 26th, 2015 Uganda Coffee Development Authority \n", "12 August 23rd, 2017 Specialty Coffee Association \n", "13 May 19th, 2015 Specialty Coffee Association \n", "14 July 14th, 2015 Uganda Coffee Development Authority \n", "15 July 14th, 2015 Uganda Coffee Development Authority \n", "16 April 29th, 2016 Specialty Coffee Association \n", "17 June 3rd, 2014 Specialty Coffee Association \n", "18 June 27th, 2015 Uganda Coffee Development Authority \n", "19 June 27th, 2015 Uganda Coffee Development Authority \n", "20 June 27th, 2015 Uganda Coffee Development Authority \n", "21 May 19th, 2015 Specialty Coffee Association \n", "22 June 20th, 2014 Specialty Coffee Association \n", "23 February 28th, 2013 Specialty Coffee Association \n", "24 January 18th, 2017 Specialty Coffee Association \n", "25 January 18th, 2017 Specialty Coffee Association \n", "26 December 23rd, 2015 Specialty Coffee Association \n", "27 August 25th, 2015 Specialty Coffee Association \n", "28 August 25th, 2015 Specialty Coffee Association \n", "\n", " Certification.Address \\\n", "1 e36d0270932c3b657e96b7b0278dfd85dc0fe743 \n", "2 ff7c18ad303d4b603ac3f8cff7e611ffc735e720 \n", "3 ff7c18ad303d4b603ac3f8cff7e611ffc735e720 \n", "4 e36d0270932c3b657e96b7b0278dfd85dc0fe743 \n", "5 e36d0270932c3b657e96b7b0278dfd85dc0fe743 \n", "6 ff7c18ad303d4b603ac3f8cff7e611ffc735e720 \n", "7 ff7c18ad303d4b603ac3f8cff7e611ffc735e720 \n", "8 ff7c18ad303d4b603ac3f8cff7e611ffc735e720 \n", "9 ff7c18ad303d4b603ac3f8cff7e611ffc735e720 \n", "10 e36d0270932c3b657e96b7b0278dfd85dc0fe743 \n", "11 e36d0270932c3b657e96b7b0278dfd85dc0fe743 \n", "12 ff7c18ad303d4b603ac3f8cff7e611ffc735e720 \n", "13 ff7c18ad303d4b603ac3f8cff7e611ffc735e720 \n", "14 e36d0270932c3b657e96b7b0278dfd85dc0fe743 \n", "15 e36d0270932c3b657e96b7b0278dfd85dc0fe743 \n", "16 ff7c18ad303d4b603ac3f8cff7e611ffc735e720 \n", "17 ff7c18ad303d4b603ac3f8cff7e611ffc735e720 \n", "18 e36d0270932c3b657e96b7b0278dfd85dc0fe743 \n", "19 e36d0270932c3b657e96b7b0278dfd85dc0fe743 \n", "20 e36d0270932c3b657e96b7b0278dfd85dc0fe743 \n", "21 ff7c18ad303d4b603ac3f8cff7e611ffc735e720 \n", "22 ff7c18ad303d4b603ac3f8cff7e611ffc735e720 \n", "23 ff7c18ad303d4b603ac3f8cff7e611ffc735e720 \n", "24 ff7c18ad303d4b603ac3f8cff7e611ffc735e720 \n", "25 ff7c18ad303d4b603ac3f8cff7e611ffc735e720 \n", "26 ff7c18ad303d4b603ac3f8cff7e611ffc735e720 \n", "27 ff7c18ad303d4b603ac3f8cff7e611ffc735e720 \n", "28 ff7c18ad303d4b603ac3f8cff7e611ffc735e720 \n", "\n", " Certification.Contact unit_of_measurement \\\n", "1 03077a1c6bac60e6f514691634a7f6eb5c85aae8 m \n", "2 352d0cf7f3e9be14dad7df644ad65efc27605ae2 m \n", "3 352d0cf7f3e9be14dad7df644ad65efc27605ae2 m \n", "4 03077a1c6bac60e6f514691634a7f6eb5c85aae8 m \n", "5 03077a1c6bac60e6f514691634a7f6eb5c85aae8 m \n", "6 352d0cf7f3e9be14dad7df644ad65efc27605ae2 m \n", "7 352d0cf7f3e9be14dad7df644ad65efc27605ae2 m \n", "8 352d0cf7f3e9be14dad7df644ad65efc27605ae2 m \n", "9 352d0cf7f3e9be14dad7df644ad65efc27605ae2 m \n", "10 03077a1c6bac60e6f514691634a7f6eb5c85aae8 m \n", "11 03077a1c6bac60e6f514691634a7f6eb5c85aae8 m \n", "12 352d0cf7f3e9be14dad7df644ad65efc27605ae2 m \n", "13 352d0cf7f3e9be14dad7df644ad65efc27605ae2 m \n", "14 03077a1c6bac60e6f514691634a7f6eb5c85aae8 m \n", "15 03077a1c6bac60e6f514691634a7f6eb5c85aae8 m \n", "16 352d0cf7f3e9be14dad7df644ad65efc27605ae2 m \n", "17 352d0cf7f3e9be14dad7df644ad65efc27605ae2 m \n", "18 03077a1c6bac60e6f514691634a7f6eb5c85aae8 m \n", "19 03077a1c6bac60e6f514691634a7f6eb5c85aae8 m \n", "20 03077a1c6bac60e6f514691634a7f6eb5c85aae8 m \n", "21 352d0cf7f3e9be14dad7df644ad65efc27605ae2 m \n", "22 352d0cf7f3e9be14dad7df644ad65efc27605ae2 m \n", "23 352d0cf7f3e9be14dad7df644ad65efc27605ae2 m \n", "24 352d0cf7f3e9be14dad7df644ad65efc27605ae2 m \n", "25 352d0cf7f3e9be14dad7df644ad65efc27605ae2 m \n", "26 352d0cf7f3e9be14dad7df644ad65efc27605ae2 m \n", "27 352d0cf7f3e9be14dad7df644ad65efc27605ae2 m \n", "28 352d0cf7f3e9be14dad7df644ad65efc27605ae2 m \n", "\n", " altitude_low_meters altitude_high_meters altitude_mean_meters \n", "1 1488.0 1488.0 1488.0 \n", "2 3170.0 3170.0 3170.0 \n", "3 1000.0 1000.0 1000.0 \n", "4 1212.0 1212.0 1212.0 \n", "5 1200.0 1300.0 1250.0 \n", "6 3000.0 3000.0 3000.0 \n", "7 750.0 750.0 750.0 \n", "8 3140.0 3140.0 3140.0 \n", "9 1000.0 1000.0 1000.0 \n", "10 900.0 1300.0 1100.0 \n", "11 1095.0 1095.0 1095.0 \n", "12 1000.0 1000.0 1000.0 \n", "13 750.0 750.0 750.0 \n", "14 1367.0 1367.0 1367.0 \n", "15 1488.0 1488.0 1488.0 \n", "16 1000.0 1000.0 1000.0 \n", "17 750.0 750.0 750.0 \n", "18 1600.0 1600.0 1600.0 \n", "19 1745.0 1745.0 1745.0 \n", "20 1200.0 1200.0 1200.0 \n", "21 750.0 750.0 750.0 \n", "22 750.0 750.0 750.0 \n", "23 3000.0 3000.0 3000.0 \n", "24 NaN NaN NaN \n", "25 40.0 40.0 40.0 \n", "26 795.0 795.0 795.0 \n", "27 NaN NaN NaN \n", "28 NaN NaN NaN \n", "\n", "[28 rows x 43 columns]" ] }, "execution_count": 32, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df" ] }, { "cell_type": "markdown", "id": "a94cb1c8", "metadata": {}, "source": [ "Key points:\n", "\n", "_write three things to remember from today's class_\n", "\n", "\n", "## Questions After Classroom\n", "\n", "_many overlapping questions today_\n", "\n", "## General\n", "\n", "```{dropdown} How to know which function to use in certain problems or situations\n", "This is something you build up knowledge of slowly, and, sometimes you have a\n", "general idea, but have to look up the specifics. Having domain expertise of the\n", "dataset or a collaborator that does will help you\n", "```\n", "\n", "\n", "## Clarifying\n", "\n", "\n", "```{dropdown} Is there a way to have a set show the duplicates that get discarded?\n", "no, `set` is casting the data type so it loses information\n", "```\n", "\n", "\n", "\n", "```{dropdown} being able to access the code somewhere without asking to scroll would be nice\n", "- will work on adding most code to prismia, but if I miss some, always ask.\n", "```\n", "\n", "\n", "\n", "## Course Admin\n", "\n", "```{dropdown} When will homeworks be posted/due typically?\n", "- Posted Wednesday\n", "- Due the followign Tuesday\n", "```\n", "\n", "## Questions we'll answer later\n", "\n", "\n", "```{dropdown} can you use cast a pandas dataframe into a set?\n", "- there are better ways to find unique values and remove duplicates in a dataframe\n", "\n", "```\n", "\n", "## Try it yourself\n", "\n", "\n", "- Create variables of three different types with facts about yourself. Use descriptive variable names relative to the contents, not their types." ] }, { "cell_type": "code", "execution_count": 33, "id": "34be05fa", "metadata": { "tags": [ "hide-input" ] }, "outputs": [], "source": [ "title = 'dr' #string\n", "office_number = 134 # int\n", "courses_taught = ['Programming for Data Science',\n", " 'Machine Learning for Science & Society']" ] }, { "cell_type": "markdown", "id": "86661a34", "metadata": {}, "source": [ "- Create a list, again with a descriptive name, and print out the types" ] }, { "cell_type": "code", "execution_count": 34, "id": "0d140778", "metadata": { "tags": [ "hide-input" ] }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "\n", "\n" ] } ], "source": [ "about_prof_brown_list = [title, office_number, courses_taught]\n", "\n", "# regular for loop\n", "for fact in about_prof_brown_list:\n", " print (type(fact))" ] }, { "cell_type": "markdown", "id": "a4566ba0", "metadata": {}, "source": [ "- Write a function, `type_extractor` that takes a list and a type and returns the item of that type from the list\n", "- Test your function on all three items from your dictionary.\n", "- Use one type of jupyter help on your function, what does it display? If it doesn't display anything modify your function so that help will work.\n", "- Make yourself notes in the most memorable way for you about what a DataFrame is.\n", "\n", "\n", "```{admonition} Ram Token Opportunity\n", "Contribute possible practice questions to the notes using the suggest an edit button behind the GitHub menu at the top of the page.\n", "```" ] } ], "metadata": { "jupytext": { "text_representation": { "extension": ".md", "format_name": "myst", "format_version": 0.13, "jupytext_version": "1.10.3" } }, "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", "version": "3.8.13" }, "source_map": [ 12, 20, 22, 28, 32, 34, 38, 40, 44, 46, 49, 51, 56, 58, 61, 63, 67, 69, 73, 75, 78, 80, 83, 85, 88, 90, 93, 95, 99, 101, 109, 114, 118, 122, 127, 131, 135, 140, 144, 148, 152, 157, 161, 166, 171, 175, 179, 181, 236, 243, 246, 254 ] }, "nbformat": 4, "nbformat_minor": 5 }