WEBVTT

0
00:00.270 --> 00:03.360
Now we're finally ready to tackle our project,

1
00:03.510 --> 00:08.510
and this project is based on a real-life struggle that I have. Often when I'm

2
00:09.480 --> 00:13.830
calling a company and over the phone I have to give some sort of details

3
00:13.830 --> 00:16.680
right? They'll ask me, what is your name, and can you spell it?

4
00:16.890 --> 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?

5
00:21.390 --> 00:24.390
Was that a B, what did you say? In these cases

6
00:24.390 --> 00:29.070
often I have to sort of default to some sort of Naval alphabet. where

7
00:29.070 --> 00:32.220
I say A is the alfa, N for November, G for golf.

8
00:32.610 --> 00:36.870
And then at some point I forget what E stands for and I'm like E for.. elephant?

9
00:37.530 --> 00:42.180
And there have been times where I've just completely taken the MIG and said

10
00:42.180 --> 00:46.170
things like M for mnemonic, P for pneumonia, W for wrench,

11
00:46.440 --> 00:47.880
which doesn't make any sense at all

12
00:47.880 --> 00:52.880
because these are silent letters. And I've had some very angry people,

13
00:52.950 --> 00:54.570
um, but it was quite fun.

14
00:55.110 --> 00:59.610
So now what we want to create is we want to create a tool that takes the NATO

15
00:59.610 --> 01:03.840
phonetic alphabet which was generated because it's often really,

16
01:03.840 --> 01:08.840
really important for the other side to know exactly what it is that you said and

17
01:08.970 --> 01:13.970
which letters you're spelling out so that they don't mistaken your E for a B or

18
01:15.000 --> 01:16.500
your T for a C

19
01:16.530 --> 01:20.700
cause it all sounds really similar. Head over to the course resources page

20
01:20.760 --> 01:24.120
where you can find the starting files for the NATO alphabet project.

21
01:24.990 --> 01:29.730
I want you to practice with list comprehension and with dictionary

22
01:29.730 --> 01:31.980
comprehension. But in this case,

23
01:32.010 --> 01:34.800
we're not going through a dictionary per se,

24
01:34.830 --> 01:39.830
but we're actually going through a data frame because our data lives inside a

25
01:39.930 --> 01:43.830
CSV. So we're going to be reading it using pandas.

26
01:44.130 --> 01:49.130
and then we're going to end up with a data frame. Instead of having a bog

27
01:49.410 --> 01:54.150
standard dictionary comprehension where our keywords were new_key:

28
01:54.180 --> 01:59.180
new_value for key, value in dict.items.

29
02:05.130 --> 02:08.430
Now we're going to change this for-loop

30
02:08.490 --> 02:11.330
so instead of using the simple for loop where

31
02:11.410 --> 02:12.990
we're just looping through a dictionary,

32
02:13.380 --> 02:17.670
we're going to use this particular loop. So then in this case,

33
02:17.700 --> 02:22.700
we're saying for index row in our data frame,

34
02:24.300 --> 02:28.740
and then it's .iterrows as the method.

35
02:29.220 --> 02:34.220
So basically I want you to use this different loop in order to loop through our

36
02:34.440 --> 02:39.440
data frame and then create a new dictionary using a new key and new value.

37
02:41.130 --> 02:45.390
So what exactly is it that I want you to do with this? Well,

38
02:45.420 --> 02:49.380
I want you to be able to take the CSV of NATO phonetic alphabet,

39
02:49.830 --> 02:51.690
and I want you to do two things to it.

40
02:52.140 --> 02:57.140
The first thing is for you to create a dictionary in this format.

41
03:01.000 --> 03:06.000
The format is basically the key is going to be the actual letter,

42
03:06.130 --> 03:11.130
so maybe A. And then the value is going to be the corresponding code for the NATO

43
03:12.460 --> 03:15.700
phonetic alphabet. So A actually is for alpha.

44
03:16.150 --> 03:20.530
And then the next one is B, which stands for Bravo.

45
03:21.490 --> 03:22.180
Essentially,

46
03:22.180 --> 03:26.830
we're going to take the CSV and we're going to convert it into a dictionary in

47
03:26.830 --> 03:30.190
this particular format where the keys

48
03:30.190 --> 03:34.330
are the letters inside the CSV, so that first column,

49
03:34.690 --> 03:39.690
and then the values are the corresponding code words for each of those letters.

50
03:40.630 --> 03:45.250
And the reason why we're talking about iterrows and had to loop through rows of a

51
03:45.250 --> 03:49.570
data frame instead of just getting you to get hold of the data frame

52
03:49.900 --> 03:52.270
and then just say to_dict

53
03:52.420 --> 03:56.590
like what we did before, is because it's not going to give it to you in this

54
03:56.590 --> 03:57.640
particular format.

55
03:58.000 --> 04:01.210
So you're going to have to use what you've learned about dictionary

56
04:01.210 --> 04:05.770
comprehension in order to create a dictionary in this particular format.

57
04:06.370 --> 04:08.830
And then once you've created a dictionary in this format,

58
04:08.860 --> 04:11.200
then the next step is a lot easier.

59
04:11.500 --> 04:16.500
You are going to create a list of the phonetic code words from a word that the

60
04:19.450 --> 04:20.620
user inputs.

61
04:21.940 --> 04:26.410
That way the user can use the input to type a word.

62
04:26.830 --> 04:30.430
So for example, Thomas, and then when they hit enter,

63
04:30.550 --> 04:32.740
they get a list printed out

64
04:33.010 --> 04:38.010
that is the phonetic alphabet code word for each of the letters in their input.

65
04:39.190 --> 04:41.800
So Tango, Hotel, Oscar Mike, Alpha Sierra,

66
04:41.830 --> 04:45.160
which they can then read back using our little tool.

67
04:46.210 --> 04:50.290
I would say that to do step 1 is a lot harder than to do step 2.

68
04:50.620 --> 04:54.070
But essentially, to do step 1 is a dictionary comprehension,

69
04:54.160 --> 04:58.630
creating a dictionary in this format from the CSV, and to do 

70
04:58.630 --> 05:03.630
number 2 is basically completing the project and being able to create and

71
05:03.910 --> 05:08.860
print out a list of the code words based on the word that the user inputs.

72
05:09.400 --> 05:13.570
So I want you to pause the video, have a think about how you might solve this,

73
05:13.900 --> 05:18.900
and then go ahead to the course resources and download this starting zip file so

74
05:20.170 --> 05:24.370
that you can open it up inside PyCharm and create your project.

75
05:24.880 --> 05:26.770
Pause the video and give that a go now.