1
00:00:00,480 --> 00:00:06,150
Throughout my experience with working with large data sets I've noticed some techniques that data

2
00:00:06,180 --> 00:00:14,430
collecting institutes use to safe storage and make them, their data have less space on computer disks.

3
00:00:14,430 --> 00:00:17,400
A common technique is not to use decimals.

4
00:00:17,400 --> 00:00:22,320
For example if you search for temperature data you'll not see the actual temperatures, let's say these

5
00:00:22,320 --> 00:00:23,130
are Celsius.

6
00:00:23,130 --> 00:00:28,830
You'll not see them like that but you'll see them without the dot because that's what safe storage

7
00:00:29,010 --> 00:00:29,970
in the servers.

8
00:00:30,060 --> 00:00:33,720
So one character less that means some bytes less.

9
00:00:33,720 --> 00:00:41,460
So you duty as a programmer is to actually divide all those values by 10, so that you get the actual

10
00:00:41,460 --> 00:00:42,260
data.

11
00:00:42,300 --> 00:00:48,750
So let's say these data were in some text files and we open these data with Python and the course actually

12
00:00:48,750 --> 00:00:52,380
covers how to manage, how to open text files in python.

13
00:00:52,560 --> 00:00:54,570
But let us skip that part for now.

14
00:00:54,630 --> 00:00:57,470
So let's say we got them loaded as a list here.

15
00:00:57,480 --> 00:01:00,460
Now we want to actually divide by 10.

16
00:01:00,480 --> 00:01:01,150
Any of them.

17
00:01:01,170 --> 00:01:03,030
So how do you do that.

18
00:01:03,030 --> 00:01:07,420
Well a technique is to iterate over temps.

19
00:01:07,440 --> 00:01:16,590
So for temp in temps and in each iteration you want to do temp divided by 10.

20
00:01:16,890 --> 00:01:20,340
But where do we store this temp divided by 10.

21
00:01:21,030 --> 00:01:25,900
Well we can store it in a new list, let's say new temps.

22
00:01:26,160 --> 00:01:28,190
That is an empty list for now.

23
00:01:28,200 --> 00:01:39,830
So the loop iterate through this list and in each iteration we're going to append this value to new temps.

24
00:01:40,730 --> 00:01:50,110
So append these value. That looks okay and then print out new temps.

25
00:01:50,150 --> 00:01:54,520
Let me go ahead and execute that.

26
00:01:54,770 --> 00:01:57,160
So this is the desired output.

27
00:01:57,260 --> 00:02:05,660
Now that is very correct but there is a netter way to do this in just one line of Python code, and that

28
00:02:05,660 --> 00:02:08,000
is by using list comprehensions.

29
00:02:08,210 --> 00:02:10,660
It goes like this.

30
00:02:11,060 --> 00:02:16,190
You don't have to create an empty list because a list will be generated dynamically.

31
00:02:16,190 --> 00:02:30,140
You'd say temp divided by 10 for temp in temps print new temps to see what we get executes and you get

32
00:02:30,140 --> 00:02:36,090
exactly the same output so that is a list comprehension.

33
00:02:36,090 --> 00:02:43,470
It's a way to build lists without having to create a for loop and a standard for loop because we actually

34
00:02:43,470 --> 00:02:46,550
have an inline for loop in here.

35
00:02:46,650 --> 00:02:52,820
So what's going on here is that we have an expiration and in each iteration we're going to store this

36
00:02:52,830 --> 00:02:56,190
value in the list in the new temps list.

37
00:02:56,460 --> 00:03:02,840
So this is like saying store temp divided by 10, but Python will say okay.

38
00:03:02,850 --> 00:03:04,660
But what is temp?

39
00:03:04,860 --> 00:03:05,750
It's a new variable.

40
00:03:05,760 --> 00:03:11,970
We don't, we haven't defined it to anywhere, and then we say well for temp in temps.

41
00:03:11,970 --> 00:03:13,990
So temp is a variable of temps.

42
00:03:14,010 --> 00:03:23,370
So that's how you create a list with these values for each of the values of temps, that is a list

43
00:03:23,370 --> 00:03:23,910
comprehension.

