1
00:00:00,270 --> 00:00:03,360
Now we're finally ready to tackle our project,

2
00:00:03,510 --> 00:00:08,510
and this project is based on a real-life struggle that I have. Often when I'm

3
00:00:09,480 --> 00:00:13,830
calling a company and over the phone I have to give some sort of details

4
00:00:13,830 --> 00:00:16,680
right? They'll ask me, what is your name, and can you spell it?

5
00:00:16,890 --> 00:00:21,360
So I'll have to be like A-N-G-E-L-A. And they're like, wait, was that an E?

6
00:00:21,390 --> 00:00:24,390
Was that a B, what did you say? In these cases

7
00:00:24,390 --> 00:00:29,070
often I have to sort of default to some sort of Naval alphabet. where

8
00:00:29,070 --> 00:00:32,220
I say A is the alfa, N for November, G for golf.

9
00:00:32,610 --> 00:00:36,870
And then at some point I forget what E stands for and I'm like E for.. elephant?

10
00:00:37,530 --> 00:00:42,180
And there have been times where I've just completely taken the MIG and said

11
00:00:42,180 --> 00:00:46,170
things like M for mnemonic, P for pneumonia, W for wrench,

12
00:00:46,440 --> 00:00:47,880
which doesn't make any sense at all

13
00:00:47,880 --> 00:00:52,880
because these are silent letters. And I've had some very angry people,

14
00:00:52,950 --> 00:00:54,570
um, but it was quite fun.

15
00:00:55,110 --> 00:00:59,610
So now what we want to create is we want to create a tool that takes the NATO

16
00:00:59,610 --> 00:01:03,840
phonetic alphabet which was generated because it's often really,

17
00:01:03,840 --> 00:01:08,840
really important for the other side to know exactly what it is that you said and

18
00:01:08,970 --> 00:01:13,970
which letters you're spelling out so that they don't mistaken your E for a B or

19
00:01:15,000 --> 00:01:16,500
your T for a C

20
00:01:16,530 --> 00:01:20,700
cause it all sounds really similar. Head over to the course resources page

21
00:01:20,760 --> 00:01:24,120
where you can find the starting files for the NATO alphabet project.

22
00:01:24,990 --> 00:01:29,730
I want you to practice with list comprehension and with dictionary

23
00:01:29,730 --> 00:01:31,980
comprehension. But in this case,

24
00:01:32,010 --> 00:01:34,800
we're not going through a dictionary per se,

25
00:01:34,830 --> 00:01:39,830
but we're actually going through a data frame because our data lives inside a

26
00:01:39,930 --> 00:01:43,830
CSV. So we're going to be reading it using pandas.

27
00:01:44,130 --> 00:01:49,130
and then we're going to end up with a data frame. Instead of having a bog

28
00:01:49,410 --> 00:01:54,150
standard dictionary comprehension where our keywords were new_key:

29
00:01:54,180 --> 00:01:59,180
new_value for key, value in dict.items.

30
00:02:05,130 --> 00:02:08,430
Now we're going to change this for-loop

31
00:02:08,490 --> 00:02:11,330
so instead of using the simple for loop where

32
00:02:11,410 --> 00:02:12,990
we're just looping through a dictionary,

33
00:02:13,380 --> 00:02:17,670
we're going to use this particular loop. So then in this case,

34
00:02:17,700 --> 00:02:22,700
we're saying for index row in our data frame,

35
00:02:24,300 --> 00:02:28,740
and then it's .iterrows as the method.

36
00:02:29,220 --> 00:02:34,220
So basically I want you to use this different loop in order to loop through our

37
00:02:34,440 --> 00:02:39,440
data frame and then create a new dictionary using a new key and new value.

38
00:02:41,130 --> 00:02:45,390
So what exactly is it that I want you to do with this? Well,

39
00:02:45,420 --> 00:02:49,380
I want you to be able to take the CSV of NATO phonetic alphabet,

40
00:02:49,830 --> 00:02:51,690
and I want you to do two things to it.

41
00:02:52,140 --> 00:02:57,140
The first thing is for you to create a dictionary in this format.

42
00:03:01,000 --> 00:03:06,000
The format is basically the key is going to be the actual letter,

43
00:03:06,130 --> 00:03:11,130
so maybe A. And then the value is going to be the corresponding code for the NATO

44
00:03:12,460 --> 00:03:15,700
phonetic alphabet. So A actually is for alpha.

45
00:03:16,150 --> 00:03:20,530
And then the next one is B, which stands for Bravo.

46
00:03:21,490 --> 00:03:22,180
Essentially,

47
00:03:22,180 --> 00:03:26,830
we're going to take the CSV and we're going to convert it into a dictionary in

48
00:03:26,830 --> 00:03:30,190
this particular format where the keys

49
00:03:30,190 --> 00:03:34,330
are the letters inside the CSV, so that first column,

50
00:03:34,690 --> 00:03:39,690
and then the values are the corresponding code words for each of those letters.

51
00:03:40,630 --> 00:03:45,250
And the reason why we're talking about iterrows and had to loop through rows of a

52
00:03:45,250 --> 00:03:49,570
data frame instead of just getting you to get hold of the data frame

53
00:03:49,900 --> 00:03:52,270
and then just say to_dict

54
00:03:52,420 --> 00:03:56,590
like what we did before, is because it's not going to give it to you in this

55
00:03:56,590 --> 00:03:57,640
particular format.

56
00:03:58,000 --> 00:04:01,210
So you're going to have to use what you've learned about dictionary

57
00:04:01,210 --> 00:04:05,770
comprehension in order to create a dictionary in this particular format.

58
00:04:06,370 --> 00:04:08,830
And then once you've created a dictionary in this format,

59
00:04:08,860 --> 00:04:11,200
then the next step is a lot easier.

60
00:04:11,500 --> 00:04:16,500
You are going to create a list of the phonetic code words from a word that the

61
00:04:19,450 --> 00:04:20,620
user inputs.

62
00:04:21,940 --> 00:04:26,410
That way the user can use the input to type a word.

63
00:04:26,830 --> 00:04:30,430
So for example, Thomas, and then when they hit enter,

64
00:04:30,550 --> 00:04:32,740
they get a list printed out

65
00:04:33,010 --> 00:04:38,010
that is the phonetic alphabet code word for each of the letters in their input.

66
00:04:39,190 --> 00:04:41,800
So Tango, Hotel, Oscar Mike, Alpha Sierra,

67
00:04:41,830 --> 00:04:45,160
which they can then read back using our little tool.

68
00:04:46,210 --> 00:04:50,290
I would say that to do step 1 is a lot harder than to do step 2.

69
00:04:50,620 --> 00:04:54,070
But essentially, to do step 1 is a dictionary comprehension,

70
00:04:54,160 --> 00:04:58,630
creating a dictionary in this format from the CSV, and to do 

71
00:04:58,630 --> 00:05:03,630
number 2 is basically completing the project and being able to create and

72
00:05:03,910 --> 00:05:08,860
print out a list of the code words based on the word that the user inputs.

73
00:05:09,400 --> 00:05:13,570
So I want you to pause the video, have a think about how you might solve this,

74
00:05:13,900 --> 00:05:18,900
and then go ahead to the course resources and download this starting zip file so

75
00:05:20,170 --> 00:05:24,370
that you can open it up inside PyCharm and create your project.

76
00:05:24,880 --> 00:05:26,770
Pause the video and give that a go now.

