1
00:00:00,720 --> 00:00:08,640
Now, as we discussed in our teary lecture, we need to convert all of our categorical variables and

2
00:00:08,640 --> 00:00:10,050
to a numerical variable.

3
00:00:10,680 --> 00:00:14,160
And we do that by creating dummy variables.

4
00:00:15,120 --> 00:00:18,420
So let's see how to create a dummy variable in Python.

5
00:00:20,840 --> 00:00:28,390
We'll first take a sample of our data, will use D.F. and we will apply Hegg method.

6
00:00:31,530 --> 00:00:34,370
You can see there are two categorical variables.

7
00:00:34,530 --> 00:00:37,940
That is truly underscore available and it is taking value.

8
00:00:38,070 --> 00:00:38,940
Yes and no.

9
00:00:40,230 --> 00:00:43,690
And there is another categorical variable, which is Johna.

10
00:00:43,800 --> 00:00:48,210
And it is taking value, thriller, drama, comedy and action.

11
00:00:49,790 --> 00:00:54,110
Will convert this categorical variables into dummy variable.

12
00:00:55,780 --> 00:01:03,010
And you know that the numbers of dummy variable should be one minus the numbers of category in each

13
00:01:03,010 --> 00:01:03,470
variable.

14
00:01:04,480 --> 00:01:07,040
So we will need one variable for trivia.

15
00:01:07,070 --> 00:01:11,140
Really one and three variables for John are variable.

16
00:01:13,860 --> 00:01:17,850
Now, creating dummy variables and pandas is very easy.

17
00:01:18,660 --> 00:01:23,460
You just have to use get demis method of pandas.

18
00:01:24,540 --> 00:01:28,110
So we will write Beedi Dot Guide Demis.

19
00:01:30,930 --> 00:01:36,900
And to hear our first parameter is data, since our duties, D.F. will write D.F..

20
00:01:38,790 --> 00:01:42,000
Then there are two parameters, prefix and prefix separator.

21
00:01:43,410 --> 00:01:46,560
These two are for naming your dummy variable columns.

22
00:01:47,950 --> 00:01:51,210
And we are happy with their default value, we don't want to change these values.

23
00:01:53,640 --> 00:01:55,800
And the next is columns.

24
00:01:57,560 --> 00:02:02,840
This is a parameter where we specify what columns do we need the dummy variables for?

25
00:02:03,840 --> 00:02:11,310
Since there are two columns that is truly available and John, it will pass this two columns as a list

26
00:02:11,410 --> 00:02:12,780
in this column parameter.

27
00:02:13,390 --> 00:02:19,920
So will write columns equal to then will create a list of two aloose forces through the available.

28
00:02:20,130 --> 00:02:23,850
And Johna, since this two are work at all what we call variable.

29
00:02:26,570 --> 00:02:30,800
Then there is another parameter that is Grop underscored first.

30
00:02:32,620 --> 00:02:38,260
If you remember, we discussed that the number of dummy variables should be equal to and minus one,

31
00:02:38,290 --> 00:02:40,570
that is number of categories, minus one.

32
00:02:42,940 --> 00:02:50,050
To do that, we have to write Grop underscored first, equally true, if we want a separate dummy variable

33
00:02:50,050 --> 00:02:51,550
for all the categories.

34
00:02:52,450 --> 00:02:56,260
So our treaty of a label have two categories, the US and No.

35
00:02:56,350 --> 00:03:03,970
And if we want to dummy variables for this variable, we can choose, Grob underscored for us as follows.

36
00:03:04,970 --> 00:03:08,230
But as we discussed, we want and minus one variables.

37
00:03:08,350 --> 00:03:17,780
We will select Grop underscored for us as escarole and we are again saving this table and do our data

38
00:03:17,780 --> 00:03:18,080
frame.

39
00:03:18,290 --> 00:03:20,570
So we are equating it to the yes.

40
00:03:21,530 --> 00:03:24,950
And we are changing categorical variables and numeric variable.

41
00:03:26,960 --> 00:03:27,890
We'll run this.

42
00:03:30,460 --> 00:03:36,820
Now, again, we take a sample of over the data frame using B, if not tagged.

43
00:03:42,640 --> 00:03:43,910
We executed this.

44
00:03:52,790 --> 00:04:00,740
You can see now we have converted our categorical variables into numerical variable, our first variable

45
00:04:00,740 --> 00:04:03,450
is 3D underscore, available underscore.

46
00:04:03,640 --> 00:04:06,070
Yes, this is one everywhere.

47
00:04:06,650 --> 00:04:08,690
Our 3D and it's available.

48
00:04:08,820 --> 00:04:09,310
Very well.

49
00:04:09,310 --> 00:04:10,100
It was, yes.

50
00:04:13,320 --> 00:04:17,020
And zero, where our 3D underscore available.

51
00:04:17,190 --> 00:04:18,270
Very well, it was No.

52
00:04:20,170 --> 00:04:22,750
Now we have three variables for over Johnette.

53
00:04:23,980 --> 00:04:25,120
Categorical variable.

54
00:04:25,600 --> 00:04:31,780
We have Johna underscore comedy, Johna Underscore Grama and John that underscore thriller, these are

55
00:04:32,080 --> 00:04:35,650
zero and one according to our categorical variable.

56
00:04:35,770 --> 00:04:43,310
Jonah, if the Janner was comedy, then we will have one in the Johnette underscore comedy with one.

57
00:04:46,430 --> 00:04:53,510
This is how we convert categorical variables and to numerical variables so that we can run our regression

58
00:04:53,510 --> 00:04:57,200
or classification or any other techniques on our data.
