[Script Info] Title: [Events] Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text Dialogue: 0,0:00:00.00,0:00:04.85,Default,,0000,0000,0000,,In this section, we're gonna look at a new\Nform of data, called a table. And once we Dialogue: 0,0:00:04.85,0:00:09.41,Default,,0000,0000,0000,,look at how tables work, then we're gonna\Nplay around with code that manipulates Dialogue: 0,0:00:09.41,0:00:13.97,Default,,0000,0000,0000,,tables. So it's very similar to the way\Nearlier we did images and then looked at Dialogue: 0,0:00:13.97,0:00:18.93,Default,,0000,0000,0000,,the code that manipulates images. The code\Nto work with tables will actually in some Dialogue: 0,0:00:18.93,0:00:23.67,Default,,0000,0000,0000,,ways look, similar to the code that worked\Non images. So my goal is that the real Dialogue: 0,0:00:23.67,0:00:28.49,Default,,0000,0000,0000,,patterns that make any sorta code work are\Ngonna start coming through. So, tables are Dialogue: 0,0:00:28.49,0:00:33.27,Default,,0000,0000,0000,,a really common way to organize data on\Nthe computer. So as a running example for Dialogue: 0,0:00:33.27,0:00:37.82,Default,,0000,0000,0000,,this section, I'm gonna use the social\Nsecurity baby names database. So the Dialogue: 0,0:00:37.82,0:00:42.30,Default,,0000,0000,0000,,social security administration does\Nretirement benefits and stuff in the US. Dialogue: 0,0:00:42.48,0:00:46.100,Default,,0000,0000,0000,,But they also happen to track, every year.\NWhat names are given to babies born in Dialogue: 0,0:00:46.100,0:00:51.25,Default,,0000,0000,0000,,that year in the US? And so that's gonna\Nbe kinda fun data set that we're gonna Dialogue: 0,0:00:51.25,0:00:55.61,Default,,0000,0000,0000,,use, So here I've, I've structured this as\Nan example of a table. So, as I was Dialogue: 0,0:00:55.61,0:00:59.81,Default,,0000,0000,0000,,saying, table's a way of storing data.\NIt's basically, you can think of it as Dialogue: 0,0:00:59.81,0:01:04.22,Default,,0000,0000,0000,,like a rectangle. So the way the table\Nworks is that it is first organized into Dialogue: 0,0:01:04.22,0:01:08.68,Default,,0000,0000,0000,,fields. So the baby data is organized into\Nfour fields and the fields are name, rank, Dialogue: 0,0:01:08.68,0:01:13.20,Default,,0000,0000,0000,,gender and year, Look at the other fields\Nas basically as the columns that make this Dialogue: 0,0:01:13.20,0:01:18.77,Default,,0000,0000,0000,,thing up, And then the data is stored in\Nwhat we'll call rows. So here's the first Dialogue: 0,0:01:18.77,0:01:24.48,Default,,0000,0000,0000,,row has the data for the name Jacob, so it\Nsays the name is Jacob, the rank is one Dialogue: 0,0:01:24.48,0:01:30.40,Default,,0000,0000,0000,,for that name and what rank one for this\Ndata set is that Jacob is the most popular Dialogue: 0,0:01:30.40,0:01:36.08,Default,,0000,0000,0000,,boy name for babies born in 2010. Then we\Nhave gender boys in years 2010. So the Dialogue: 0,0:01:36.08,0:01:40.97,Default,,0000,0000,0000,,second row has another name. So each name\Nhas its own row. So in this case it says Dialogue: 0,0:01:40.97,0:01:46.06,Default,,0000,0000,0000,,the name is Isabella, the rank is one. So\Nwhat that means is Isabella was The most Dialogue: 0,0:01:46.06,0:01:51.76,Default,,0000,0000,0000,,popular girl name for babies born in 2010.\NSo, then we see, Ethan has rank two for Dialogue: 0,0:01:51.76,0:01:57.39,Default,,0000,0000,0000,,boy names. Sophia has rank two for girls,\Nand so on. So it, the, the table just has Dialogue: 0,0:01:57.39,0:02:03.72,Default,,0000,0000,0000,,all the names. In this case there, they're\Nshown, sorted by rank. So there's o ne row Dialogue: 0,0:02:03.72,0:02:09.14,Default,,0000,0000,0000,,per name. In this case it has the 1,000\Ntop boy names and the 1,000 top girl Dialogue: 0,0:02:09.14,0:02:14.52,Default,,0000,0000,0000,,names. So, it's, there's 2,000 rows\Noverall. So as I was saying, tables are Dialogue: 0,0:02:14.52,0:02:19.28,Default,,0000,0000,0000,,really common for storing all sorts of\Ndata on the computer. You may have heard Dialogue: 0,0:02:19.28,0:02:23.86,Default,,0000,0000,0000,,the term database. So, a database is a\Nrelated concept to this, sort of simple, Dialogue: 0,0:02:23.86,0:02:28.57,Default,,0000,0000,0000,,basic idea of a table. Generally the way\Nthis works is that the fields are, are, or Dialogue: 0,0:02:28.57,0:02:33.04,Default,,0000,0000,0000,,you can think of them as the categories,\Nthe number of fields is not very big. Dialogue: 0,0:02:34.40,0:02:39.05,Default,,0000,0000,0000,,Fields, and there might be eight or ten or\Nsomething. So they represent kinda the Dialogue: 0,0:02:39.05,0:02:43.37,Default,,0000,0000,0000,,fixed categories we wanna keep track of.\NAnd then the number of rows could be Dialogue: 0,0:02:43.37,0:02:47.68,Default,,0000,0000,0000,,enormous. It might be millions or maybe\Neven billions of rows. So I'll just, Dialogue: 0,0:02:47.85,0:02:52.55,Default,,0000,0000,0000,,mention a couple examples. So you could\Nthink of your, your email inbox is maybe Dialogue: 0,0:02:52.55,0:02:57.18,Default,,0000,0000,0000,,stored in a table on the computer. So the\Nway that would work is, well, what would Dialogue: 0,0:02:57.18,0:03:01.47,Default,,0000,0000,0000,,the fields be? The fields might be\Nsomething like from, and to, and date, and Dialogue: 0,0:03:01.47,0:03:06.27,Default,,0000,0000,0000,,subject, and, you know, a few other things\Nthat you store, per message. And then one Dialogue: 0,0:03:06.27,0:03:10.85,Default,,0000,0000,0000,,row is just one message. So each message\Ngets its own row, and then we have this, Dialogue: 0,0:03:11.02,0:03:15.48,Default,,0000,0000,0000,,fixed number of fields. So then when you\Ngo to your inbox, well, there might be. Dialogue: 0,0:03:15.48,0:03:19.43,Default,,0000,0000,0000,,10,000 rows in there for all your email\Nand maybe when you go to your inbox it Dialogue: 0,0:03:19.43,0:03:23.48,Default,,0000,0000,0000,,just selects the ten most recent ones and\Nshows you, maybe not all the fields, but Dialogue: 0,0:03:23.48,0:03:28.08,Default,,0000,0000,0000,,maybe the most important fields from that\Nmessage. Another example is Craig's List. Dialogue: 0,0:03:28.08,0:03:32.39,Default,,0000,0000,0000,,Or, you know, any sorta online auction\Nsite. Where maybe it's stored, it could be Dialogue: 0,0:03:32.39,0:03:36.93,Default,,0000,0000,0000,,stored in a table where one row is gonna\Nbe one item for sale. And then the fields Dialogue: 0,0:03:36.93,0:03:41.40,Default,,0000,0000,0000,,would again be sorta the categories that\Nyou want for one item. So the categories, Dialogue: 0,0:03:41.40,0:03:45.99,Default,,0000,0000,0000,,the fields might be the price, the date it\Nwas listed. Maybe a short description, and Dialogue: 0,0:03:45.99,0:03:50.69,Default,,0000,0000,0000,,a long description, and a few things like\Nthat. So those are just a couple examples Dialogue: 0,0:03:50.69,0:03:55.17,Default,,0000,0000,0000,,of how many of the things you deal with\Nday to day often, back on the computer, Dialogue: 0,0:03:55.17,0:03:59.82,Default,,0000,0000,0000,,that's gonna be stored in some kinda\Ntable. Alright, so to make this real, I Dialogue: 0,0:03:59.82,0:04:05.98,Default,,0000,0000,0000,,wanna look at co de to manipulate, tables.\NAnd I'm gonna use the baby name table as Dialogue: 0,0:04:05.98,0:04:11.84,Default,,0000,0000,0000,,sort of our, our working example for a, a\Ncouple sections here. So, in this case, Dialogue: 0,0:04:11.84,0:04:17.51,Default,,0000,0000,0000,,the baby data for 2010 is stored in,\Nbaby-2010.csv. I should just mention, CSV Dialogue: 0,0:04:17.51,0:04:22.99,Default,,0000,0000,0000,,stands for Comma Separated Values. It's a\Nstandard for storing, essentially table Dialogue: 0,0:04:22.99,0:04:28.13,Default,,0000,0000,0000,,data in a text file, and it's a really\Nsimple, fairly old standard. So it's a Dialogue: 0,0:04:28.13,0:04:33.54,Default,,0000,0000,0000,,pretty, you know, easy way to interchange\Ndata from one program to another. So in Dialogue: 0,0:04:33.54,0:04:39.04,Default,,0000,0000,0000,,terms of the code, I'll make my analogy to\Nimages. So for images, we had four pixel Dialogue: 0,0:04:39.04,0:04:44.47,Default,,0000,0000,0000,,colon images, And that would loop through\Nall the pixels in the image, and for each Dialogue: 0,0:04:44.47,0:04:49.22,Default,,0000,0000,0000,,pixel. Everyone, whatever this code was\Ninside the colon braces. So, for the table Dialogue: 0,0:04:49.22,0:04:53.94,Default,,0000,0000,0000,,to be very similar we're going to have\Nfour row colon table, And what that's Dialogue: 0,0:04:53.94,0:04:58.71,Default,,0000,0000,0000,,going to do is it's just going to loop\Nthrough each row through the table. So, it Dialogue: 0,0:04:58.71,0:05:03.48,Default,,0000,0000,0000,,just starts from the top and go through\Neach one. And for each row it's going to Dialogue: 0,0:05:03.48,0:05:07.84,Default,,0000,0000,0000,,run whatever code I put in the colon\Nbraces. So, here is our first example. Dialogue: 0,0:05:08.44,0:05:13.17,Default,,0000,0000,0000,,That is the line, very similar to, loading\Nan image. So that's the line that, grabs Dialogue: 0,0:05:13.17,0:05:17.35,Default,,0000,0000,0000,,the table and stores it in a variable,\Nwhich I will inevitably just call the Dialogue: 0,0:05:17.35,0:05:22.02,Default,,0000,0000,0000,,table, And then here I have the four loop,\Nsorta looking through all the rows. And in Dialogue: 0,0:05:22.02,0:05:26.64,Default,,0000,0000,0000,,this case, the simplest thing I'm gonna do\Nis I'm just gonna say, print row. So, I'm Dialogue: 0,0:05:26.64,0:05:31.04,Default,,0000,0000,0000,,just gonna, essentially just, you know,\Nlook at a, print each row in the data. So Dialogue: 0,0:05:31.04,0:05:36.78,Default,,0000,0000,0000,,this is the baby data, so if I run this.\NThere is row one and row two and so on, So Dialogue: 0,0:05:36.78,0:05:42.94,Default,,0000,0000,0000,,you can see that Jacob, Isabel, Ethan,\Nthose fairly popular names. It actually Dialogue: 0,0:05:42.94,0:05:49.09,Default,,0000,0000,0000,,made my web page quite tall because of\Ncourse there is two thousand of these Dialogue: 0,0:05:49.09,0:05:55.65,Default,,0000,0000,0000,,things. So you know there's Courtney with\Na K The 637 popular girl names. So it runs Dialogue: 0,0:05:55.65,0:06:01.81,Default,,0000,0000,0000,,all the way down here as I was saying.\NOops, to a, to a thousand. So Acre and an Dialogue: 0,0:06:01.81,0:06:06.67,Default,,0000,0000,0000,,Danea, So That is one thing, so what, I\Nguess what this shows, sort of, a bulk Dialogue: 0,0:06:06.67,0:06:11.60,Default,,0000,0000,0000,,output thing, but what it shows is, that\Nline ran 2,000 times. Once for each row in Dialogue: 0,0:06:11.60,0:06:16.54,Default,,0000,0000,0000,,the table. So, just as with the image, the\Nfour loop just went through and looked at Dialogue: 0,0:06:16.54,0:06:21.78,Default,,0000,0000,0000,,each one. Alright so here I'm gonna comma\Nthis out and run again just to get rid of Dialogue: 0,0:06:21.78,0:06:26.83,Default,,0000,0000,0000,,the output so I can have my webpage and\NI'll be a mile high here. So what are we Dialogue: 0,0:06:26.83,0:06:31.64,Default,,0000,0000,0000,,gonna do with the table? Just looping\Nthrough and printing each row, that's like Dialogue: 0,0:06:31.64,0:06:36.60,Default,,0000,0000,0000,,[laugh], like for Craigslist or for your\Nemail. That's never what you want. What we Dialogue: 0,0:06:36.60,0:06:41.84,Default,,0000,0000,0000,,want is to loop through all the rows and\Njust pick out the six or two of the 2,000 Dialogue: 0,0:06:41.84,0:06:47.34,Default,,0000,0000,0000,,that we want. This is very common thing to\Ndo with table [inaudible]. It is sometimes Dialogue: 0,0:06:47.34,0:06:52.46,Default,,0000,0000,0000,,called in database terminology a quarry.\NThat I'm going to kind of sort of narrow Dialogue: 0,0:06:52.46,0:06:57.20,Default,,0000,0000,0000,,down to just the rows I want. So, let's\Ntalk about the code to do that. So Dialogue: 0,0:06:57.39,0:07:02.82,Default,,0000,0000,0000,,[inaudible] we're going to do this with an\NIF statement, Put an IF statement inside Dialogue: 0,0:07:02.82,0:07:08.29,Default,,0000,0000,0000,,the loop and in the IF task we will write\Na task to select just some of the rows. So Dialogue: 0,0:07:08.29,0:07:12.77,Default,,0000,0000,0000,,here's gonna be my first example. So here\Nis the four loop. So that's looping Dialogue: 0,0:07:12.77,0:07:17.55,Default,,0000,0000,0000,,through all the rows. And then inside the\Nfour loop, I've got this if statement. So Dialogue: 0,0:07:17.55,0:07:22.14,Default,,0000,0000,0000,,what's gonna happen is, this highlighted\Ncode is gonna run again and again and Dialogue: 0,0:07:22.14,0:07:27.62,Default,,0000,0000,0000,,again, once for each row in the thing. And\Nso what I've done. So I've, written a test Dialogue: 0,0:07:27.62,0:07:33.79,Default,,0000,0000,0000,,here, and my, the goal here is, in this\Ncase, is to just pick out the rows where Dialogue: 0,0:07:33.79,0:07:39.85,Default,,0000,0000,0000,,the rank is six. And so, let me talk about\Nhow that works. So what's gonna happen is Dialogue: 0,0:07:39.85,0:07:44.06,Default,,0000,0000,0000,,that highlighted test, that test is gonna\Nbe evaluated once for every row. So in a Dialogue: 0,0:07:44.06,0:07:48.54,Default,,0000,0000,0000,,sense 2000 times. So, what I'm gonna do is\Nstructure the test so it's true for a row Dialogue: 0,0:07:48.54,0:07:52.71,Default,,0000,0000,0000,,I care about. And then inside of here I'll\Nput a print, so it'll print the ones I Dialogue: 0,0:07:52.71,0:07:56.77,Default,,0000,0000,0000,,care about. In all the other rows this\Nwill be false, and so it won't print the, Dialogue: 0,0:07:56.77,0:08:01.45,Default,,0000,0000,0000,,won't print those. All right, so how does\Nthis work? So just as for the pixel, we Dialogue: 0,0:08:01.45,0:08:06.58,Default,,0000,0000,0000,,had get red and get green and get blue the\Nrow has get field. And so you could, Dialogue: 0,0:08:06.58,0:08:11.64,Default,,0000,0000,0000,,remember we called it a row because all\Nthe way across it has a bunch of different Dialogue: 0,0:08:11.64,0:08:16.41,Default,,0000,0000,0000,,fields. So you can say, well, which field\Ndo you want? The way this works is each Dialogue: 0,0:08:16.41,0:08:21.56,Default,,0000,0000,0000,,field has a n ame. In this case, the names\Nare name, rank, gender and year. So in Dialogue: 0,0:08:21.56,0:08:25.90,Default,,0000,0000,0000,,this case, I say get field. And then,\Nwithin the parentheses, I say in a string, Dialogue: 0,0:08:25.90,0:08:30.35,Default,,0000,0000,0000,,which field do I want by name? So in this\Ncase, I'm, like, oh right. I wanna go to Dialogue: 0,0:08:30.35,0:08:34.62,Default,,0000,0000,0000,,the row, and I wanna pick out the rank. So\Nthis highlighted part that goes to the Dialogue: 0,0:08:34.62,0:08:38.49,Default,,0000,0000,0000,,row. And that picks out the rank. Just as\Nbefore we would have a pixel dot get red Dialogue: 0,0:08:38.49,0:08:42.04,Default,,0000,0000,0000,,and that would pick, that would pull the\Nred just out of the pixel, so this is Dialogue: 0,0:08:42.04,0:08:46.96,Default,,0000,0000,0000,,analogous but for a table. So now my call\Nhere for this example is I wanted to just Dialogue: 0,0:08:46.96,0:08:51.72,Default,,0000,0000,0000,,show what the rows where the rank\N[inaudible] required new little bit of Dialogue: 0,0:08:51.72,0:08:56.93,Default,,0000,0000,0000,,code. So having picked the rank out here,\Nthen I says equals, equals, which I think Dialogue: 0,0:08:56.93,0:09:02.15,Default,,0000,0000,0000,,we already used before, but two equal\Nsigns next to each other that compares two Dialogue: 0,0:09:02.15,0:09:07.11,Default,,0000,0000,0000,,things for equality, it tested they are\Nthe same. And so road get field rank Dialogue: 0,0:09:07.11,0:09:11.92,Default,,0000,0000,0000,,equal, equal six. What that says is, get\Nthe rank out, and test if it's six. And if Dialogue: 0,0:09:11.92,0:09:16.73,Default,,0000,0000,0000,,it's six, we'll say that that's, the test\Nis true. And if it's not, we'll say it's Dialogue: 0,0:09:16.73,0:09:21.70,Default,,0000,0000,0000,,false. So, let me just try running this.\NSo if I run it, what's happened is, it Dialogue: 0,0:09:21.70,0:09:26.51,Default,,0000,0000,0000,,went through all 2,000 rows. And for these\Ntwo rows, that test was true, Because Dialogue: 0,0:09:26.51,0:09:31.33,Default,,0000,0000,0000,,that's the case where the, the rank was\Nsix. And obviously, you know, I could say Dialogue: 0,0:09:31.33,0:09:35.62,Default,,0000,0000,0000,,it, like, 127 here or whatever. And then\Nwe would get the two rows. It just Dialogue: 0,0:09:35.62,0:09:40.27,Default,,0000,0000,0000,,happens; each rank number has one boy name\Nand one girl name in the Stata set. So, Dialogue: 0,0:09:40.44,0:09:46.11,Default,,0000,0000,0000,,that's why I keep getting two rows here.\NSo let me try another example. Oh, also I Dialogue: 0,0:09:46.11,0:09:53.78,Default,,0000,0000,0000,,should mention a, a warning about this. So\NI'll change this back to six, quick. So Dialogue: 0,0:09:53.78,0:09:58.41,Default,,0000,0000,0000,,this use of the two equals for equality is\Na little odd in computer code. I think it Dialogue: 0,0:09:58.41,0:10:02.60,Default,,0000,0000,0000,,would be very reasonable to think, oh,\Nwhat, shouldn't there be just one equal Dialogue: 0,0:10:02.60,0:10:06.80,Default,,0000,0000,0000,,sign? Right? If rank equals six? And\Nunfortunately the single equal sign in Dialogue: 0,0:10:06.80,0:10:10.99,Default,,0000,0000,0000,,JavaScript already has been used for\Nvariable assignment. It's kinda already Dialogue: 0,0:10:10.99,0:10:15.80,Default,,0000,0000,0000,,dedicated to meaning that. And so they\Ncouldn't use it for quality, so that's why Dialogue: 0,0:10:15.80,0:10:20.36,Default,,0000,0000,0000,,there's this different symbol for equa\Nlity. Now, just for this class. So the, Dialogue: 0,0:10:20.36,0:10:25.17,Default,,0000,0000,0000,,it's actually a pretty common error coding\Nto sort of accidentally type a single Dialogue: 0,0:10:25.17,0:10:30.39,Default,,0000,0000,0000,,equal sign, when someone meant two equal\Nsigns for comparison. In this case. I've Dialogue: 0,0:10:30.39,0:10:35.35,Default,,0000,0000,0000,,outfitted the run button with some special\Nchecking code, where it notices if in an Dialogue: 0,0:10:35.35,0:10:40.50,Default,,0000,0000,0000,,if test, it sees a single equal sign, And\Nit gives this error message that basically Dialogue: 0,0:10:40.50,0:10:45.64,Default,,0000,0000,0000,,says, hey, did, did you maybe mean to use,\Ntwo equal signs? So, that is an easy error Dialogue: 0,0:10:45.64,0:10:49.30,Default,,0000,0000,0000,,to make, but. Hit the run button and we'll\Ncatch it for you. That, that's something I Dialogue: 0,0:10:49.30,0:10:54.32,Default,,0000,0000,0000,,just did for this class, Alright so now\Nlet me do a now let me do another example. Dialogue: 0,0:10:54.50,0:10:59.65,Default,,0000,0000,0000,,So the test I did before I tested if rank\Nwas six but really any kind of test as we Dialogue: 0,0:10:59.65,0:11:04.60,Default,,0000,0000,0000,,were doing before with images, will work\Nhere. So in this case what I'm going to do Dialogue: 0,0:11:04.60,0:11:09.40,Default,,0000,0000,0000,,is I want to go through the data set and I\Nwant to find the data, let's just say, for Dialogue: 0,0:11:09.40,0:11:14.31,Default,,0000,0000,0000,,Alice. So as I mentioned before forget\Nfield you can just patch in the name for Dialogue: 0,0:11:14.31,0:11:19.00,Default,,0000,0000,0000,,any field. So, you would need to know what\Nthe field names are. For this data set Dialogue: 0,0:11:19.00,0:11:23.69,Default,,0000,0000,0000,,they are name ranked under here and here.\NSo, here I will go to the row and say, hey Dialogue: 0,0:11:23.69,0:11:28.37,Default,,0000,0000,0000,,give me the name field. So I'll say, name\Nthere. And then I'll, I'll equals, equals, Dialogue: 0,0:11:28.37,0:11:32.73,Default,,0000,0000,0000,,test if the name is, is the same as Alice.\NSo, if I run that. In effect what this Dialogue: 0,0:11:32.73,0:11:36.82,Default,,0000,0000,0000,,does is it just pulls out the Alice row.\NIt goes through all the rows, does this Dialogue: 0,0:11:36.82,0:11:41.02,Default,,0000,0000,0000,,test, and if the name is Alice, let's hear\Nthe English translation of this, then it Dialogue: 0,0:11:41.02,0:11:46.44,Default,,0000,0000,0000,,prints the row out. Alright, so that's the\Nbasic pattern. So let me just work a few Dialogue: 0,0:11:46.44,0:11:51.16,Default,,0000,0000,0000,,examples for this. So, the pattern is\Ngonna be, [inaudible] just as I was doing. Dialogue: 0,0:11:51.16,0:11:55.57,Default,,0000,0000,0000,,We have a four loop, there's an if\Nstatement side of it. And then really, all Dialogue: 0,0:11:55.57,0:12:00.46,Default,,0000,0000,0000,,of the action is in the parentheses of the\Ntest. Where I say row.getfield something, Dialogue: 0,0:12:00.46,0:12:05.11,Default,,0000,0000,0000,,and I have some test about it. So let's\Ntry these. So if I run it this way, we Dialogue: 0,0:12:05.11,0:12:10.06,Default,,0000,0000,0000,,pull out, it says, if name is equal, equal\Nto Alice, I get the Alice row. If I wanted Dialogue: 0,0:12:10.06,0:12:14.83,Default,,0000,0000,0000,,to look for something else, pull out some\Nother data, we could say Robert. So Alice Dialogue: 0,0:12:14.83,0:12:25.60,Default,,0000,0000,0000,,is 172. Ro bert is 54. Let's try Abby.\N284. So, what's happening is, this Dialogue: 0,0:12:25.60,0:12:31.07,Default,,0000,0000,0000,,highlighted test is happening all 2000\Ntimes. And it's just a question of which Dialogue: 0,0:12:31.07,0:12:37.09,Default,,0000,0000,0000,,rows are we, are we picking out there? I\Ndid Robert before. I'll show you something Dialogue: 0,0:12:37.09,0:12:43.71,Default,,0000,0000,0000,,kind of funny. If you do Bob and you run.\NNothing appears here. What's going on Dialogue: 0,0:12:43.71,0:12:47.74,Default,,0000,0000,0000,,there is actually no one names their kid\NBob. Apparently, so what's happening is Dialogue: 0,0:12:47.74,0:12:51.97,Default,,0000,0000,0000,,that we are getting no... Zero printing is\Nhappening here. This thing was just never Dialogue: 0,0:12:51.97,0:12:56.20,Default,,0000,0000,0000,,true. That's sort of the pattern on the\Nform I guess for just as how people name Dialogue: 0,0:12:56.20,0:13:00.38,Default,,0000,0000,0000,,babies is that they tend of the form...\NThey put a long name, like Robert. So, and Dialogue: 0,0:13:00.38,0:13:04.51,Default,,0000,0000,0000,,then Bob is like, they don't put on the\Nform. Maybe that's just what they actually Dialogue: 0,0:13:04.51,0:13:09.56,Default,,0000,0000,0000,,call the kid. Alright, so let me try a\Ndifferent test. Let's say I wanna test if Dialogue: 0,0:13:09.56,0:13:14.63,Default,,0000,0000,0000,,the rank is one. So I would change get\Nfield, and I would type rank here. And Dialogue: 0,0:13:14.63,0:13:20.54,Default,,0000,0000,0000,,then the equals, equals. I can say one,\Nsure. So that gives me the two rows Jacob Dialogue: 0,0:13:20.78,0:13:26.88,Default,,0000,0000,0000,,and Isabelle. We saw four, those are rank\None. So. [inaudible], what was the other Dialogue: 0,0:13:26.88,0:13:32.47,Default,,0000,0000,0000,,one we did 1,000. So say rank equals a\Nthousand. And we get crew ending. So the Dialogue: 0,0:13:32.68,0:13:38.34,Default,,0000,0000,0000,,test we did earlier with images like less\Nthan, less than equal to. All that stuff Dialogue: 0,0:13:38.34,0:13:44.14,Default,,0000,0000,0000,,works too. So let's say I wanna look at,\Nif the rank is less than ten. [inaudible] Dialogue: 0,0:13:44.14,0:13:49.57,Default,,0000,0000,0000,,say less than ten and when I run that. You\Ncan see I get, rank one, rank two, rank Dialogue: 0,0:13:49.57,0:13:54.42,Default,,0000,0000,0000,,three, rank... All these are rank numbers\Nwhere the less than ten test is true. Dialogue: 0,0:13:54.61,0:13:59.83,Default,,0000,0000,0000,,Although you'll notice the last I get is\NAiden and Cloe, number nine. The rows Dialogue: 0,0:13:59.83,0:14:05.12,Default,,0000,0000,0000,,where rank is ten, I don't get. And that's\Nbecause this form of less than is a strict Dialogue: 0,0:14:05.12,0:14:10.41,Default,,0000,0000,0000,,less than. So it's true for nine but it's\Nnot true for ten. If you want, there's Dialogue: 0,0:14:10.41,0:14:15.25,Default,,0000,0000,0000,,another form of less than where you're\Nlike, where you wanna say less than or Dialogue: 0,0:14:15.25,0:14:19.37,Default,,0000,0000,0000,,equal to. And, I don't think we did this\Nfor the images but it's just, what you do Dialogue: 0,0:14:19.37,0:14:23.24,Default,,0000,0000,0000,,is you put in an equal sign right after\Nit. That means less than or equal to. So Dialogue: 0,0:14:23.24,0:14:29.73,Default,,0000,0000,0000,,if I run it now then it goes through ten.\NSo, and that works for, greater than as Dialogue: 0,0:14:29.73,0:14:35.05,Default,,0000,0000,0000,,well. Alright, so let's try a, let's try a\Ngreater than one. So I could say, I would Dialogue: 0,0:14:35.05,0:14:40.60,Default,,0000,0000,0000,,like to see all the rows where the rank is\Ngreater than 990, let's say. And so what Dialogue: 0,0:14:40.60,0:14:44.97,Default,,0000,0000,0000,,I, so I get 991, 92, da, da, da, da, up\Nthrough 1000. Okay, let me just try one Dialogue: 0,0:14:44.97,0:14:50.14,Default,,0000,0000,0000,,more. I, so [inaudible] examples with name\Nand rank. And [inaudible] inevitably, I'm Dialogue: 0,0:14:50.14,0:14:54.75,Default,,0000,0000,0000,,calling, road.getfield, and just changing\Nwhat string is there to pull out a Dialogue: 0,0:14:54.75,0:15:00.23,Default,,0000,0000,0000,,different field. I'll try pulling out the,\Nthe gender field. And this case, the way Dialogue: 0,0:15:00.23,0:15:04.72,Default,,0000,0000,0000,,the data's coded, the gender field is\Nit's, it's, it's just strings. So it's Dialogue: 0,0:15:04.72,0:15:09.40,Default,,0000,0000,0000,,either the string boy or string girl. So\Nif I were to say, if gender is equal, Dialogue: 0,0:15:09.40,0:15:15.19,Default,,0000,0000,0000,,equal to girl. Hit one then I get [sound]\NI mean if you look where it say scroll Dialogue: 0,0:15:15.19,0:15:20.35,Default,,0000,0000,0000,,here, what's happened is I have just\Ngotten all 1,000 girl bros. And, and none Dialogue: 0,0:15:20.35,0:15:25.86,Default,,0000,0000,0000,,of the 1000 [inaudible] woops. Alrighty.\NSorry, let me get this back. So this is Dialogue: 0,0:15:25.86,0:15:31.03,Default,,0000,0000,0000,,ju-, just a trick where I comment out\Nprint, so it prints nothing, and run it Dialogue: 0,0:15:31.03,0:15:36.44,Default,,0000,0000,0000,,again. So then, that way, it just, it just\Nblanks out the output here. So. Just to Dialogue: 0,0:15:36.63,0:15:41.07,Default,,0000,0000,0000,,repeat what the pattern is. So, t, t,\Nthese first few lines were always the Dialogue: 0,0:15:41.07,0:15:46.31,Default,,0000,0000,0000,,same. And I guess I was always [inaudible]\Nthe row. So the, that was always the same. Dialogue: 0,0:15:46.31,0:15:51.30,Default,,0000,0000,0000,,What I change is the if test. And the gist\Nof it, the pattern tended to be I would Dialogue: 0,0:15:51.30,0:15:56.11,Default,,0000,0000,0000,,say row.getField, whatever field I care\Nabout. And then I would write equals, Dialogue: 0,0:15:56.11,0:16:00.98,Default,,0000,0000,0000,,equals or less than or equal to or\Nsomething. Let's say on the rank or equal, Dialogue: 0,0:16:00.98,0:16:05.85,Default,,0000,0000,0000,,equal to the name to, in a sense, pull out\Nthe rows. And the rule was, I'm pulling Dialogue: 0,0:16:05.85,0:16:12.68,Default,,0000,0000,0000,,out a row, if this test is true. And so,\Nwith that in mind, well this can be a good Dialogue: 0,0:16:12.68,0:16:15.04,Default,,0000,0000,0000,,source of some exercises.