WEBVTT

00:00.780 --> 00:01.930
Hi everybody.

00:02.010 --> 00:08.340
This video is a sworn to X causes to object oriented programming and I promise you that it's only a

00:08.340 --> 00:09.460
short x cause.

00:09.460 --> 00:19.630
So first off all we import pandas SPDC and we import our Titanic file and save it in the available Titanic.

00:19.950 --> 00:22.320
And let's have a look at the first five froze.

00:22.350 --> 00:27.750
So we already know the data frame here and in Piceance everything is not checked.

00:27.750 --> 00:36.250
So also our Titanic tabular data or data frame is an object and we can also check the data type of followed

00:36.630 --> 00:37.460
tabular data.

00:37.470 --> 00:40.760
So let's check the type of Titanic

00:43.470 --> 00:50.370
so what Titanic tabular data is of the data type data frame or in other words it's an instance of the

00:50.370 --> 00:58.470
class pinned us data frame and with all objects that object specific attributes and methods specifically

00:58.470 --> 01:00.250
designed for that data type.

01:00.450 --> 01:07.950
So over many years more than 800 developers contributed to the design methods and attributes especially

01:07.950 --> 01:12.030
for lots and messy data organized in a tabular manner.

01:12.090 --> 01:15.900
And this effort makes panda so a powerful tool.

01:16.170 --> 01:22.590
But before we move on to methods and attributes of our pendants data frame we know that they are also

01:22.590 --> 01:26.940
built and functions in Python that can be applied to many data types.

01:26.940 --> 01:33.330
So for example RF and the length function which we can apply to lists to put saw also an umpire race

01:33.810 --> 01:39.480
and the links function returns to the amount of elements in a list or why it took root.

01:40.200 --> 01:47.250
And we can also pass a data frame object to pass input and functions and sometimes we get a head full

01:47.270 --> 01:48.520
resolve and sometimes not.

01:48.520 --> 01:56.610
And sometimes it's not even defined to pass a data frame to a specific Python bit and function.

01:56.610 --> 02:02.930
All right so let's start and then let's pass to the Python boot and function lengths from our data frame

02:02.940 --> 02:03.650
Titanic

02:06.890 --> 02:09.030
and Python returns us 891.

02:09.150 --> 02:15.110
So so from the last session we know that our Titanic data frame has eight hundred ninety one rows so

02:15.170 --> 02:20.450
the links function returns us and the amount of growth of our data frame.

02:20.840 --> 02:24.350
And we already know also the around function.

02:24.350 --> 02:30.860
So we can pass our Titanic data frame and let's say you want to to 0 digits.

02:30.930 --> 02:38.600
Let's see what we get here and we can see here that by using the around function each float object and

02:38.600 --> 02:46.500
our data frame is around the 2 0 digits so if we can see here the faster our first passenger paid seven

02:46.500 --> 02:53.760
point two five pound or dollar and this was from the tour seven point zero and also here the second

02:53.760 --> 03:00.420
passenger paid seventy one point two eight dollars so pounds and this was all surrounded 271 so the

03:00.420 --> 03:04.560
round function round of float objects in our data frame by default

03:07.690 --> 03:14.590
and we can also try to transform our data frame into an integer by using the int function.

03:15.400 --> 03:22.270
So let's see if this works here and now so we're getting an error message into the argument must be

03:22.270 --> 03:26.400
a string a bytes like object or a number not a data frame.

03:26.440 --> 03:35.090
So the integer function is not defined for a data frame and we can also use the main function for example

03:35.090 --> 03:39.140
which calculates in that list the minimum element in the list.

03:39.140 --> 03:44.850
So let's see what we get here and we get to your age so why do we get here.

03:44.860 --> 03:48.580
Age so if we have a look at our data frame in our columns here.

03:48.710 --> 03:54.120
So alphabetically speaking HS and the very first elements starting with an A.

03:54.170 --> 03:59.990
So when passing a data frame to the main function some returns as the minimum column later.

04:00.020 --> 04:06.290
So in this case it's sphere H because it's starting with an A and I think this was not what we intended.

04:06.380 --> 04:14.300
So maybe our intention was to get the let's say the youngest pessimism or data frame or the lowest fare

04:14.330 --> 04:15.610
paid by a peasant shop.

04:15.640 --> 04:21.830
But our intention was not to get the column label which starts wasn't any actually.

04:21.830 --> 04:22.220
All right.

04:22.220 --> 04:29.240
So now let's move to data frame attributes and the first attribute we already know

04:31.880 --> 04:41.780
so we can check the shape of our data frame and it's 891 rose and nine columns and that's also the attribute

04:41.780 --> 04:42.440
size

04:48.980 --> 04:54.710
so we get to eight thousand nineteen and uh what uh pandas return census actually year.

04:54.860 --> 04:56.980
The amount of all elements in our data frame.

04:56.990 --> 04:59.670
So we have eight hundred ninety one rows and nine columns.

04:59.690 --> 05:05.310
So eight hundred ninety one times nine gives us eight thousand ninety and elements and our data frame.

05:05.750 --> 05:12.950
And we can also specifically return the index labels.

05:12.950 --> 05:19.140
So here we have a range index starting from zero and ending at eight hundred ninety or so eight hundred

05:19.140 --> 05:24.620
ninety one excluding and we can also explicitly check the column labels

05:31.010 --> 05:36.410
so here our column labels survive peasant class sex and so on.

05:36.410 --> 05:44.970
Now let's move to data frame methods and we already learned one of the most important methods so we

05:44.970 --> 05:52.140
have the method thought had which returns us and the other very first rows of our data frame and by

05:52.140 --> 05:55.760
default the first five rows some in imparting a data frame.

05:55.770 --> 06:01.470
The method is actually the very first method we will use in order to get the very first impression of

06:01.470 --> 06:03.600
our data frame.

06:03.850 --> 06:11.860
And also we already learned about the infill method which returns us meta information on our data frame

06:13.210 --> 06:15.240
so we have eight hundred ninety one rows.

06:15.250 --> 06:21.850
We have nine columns and for each column we have a specific amount of nominal values and we have found

06:21.850 --> 06:28.540
the data type in each column and we affirm the memory usage of the total data frame.

06:28.660 --> 06:32.020
And now let's use another method call it mean

06:36.450 --> 06:42.930
so in year we get for each column the minimum value is so we know that in the survived column there

06:42.930 --> 06:49.580
are the values 0 and 1 and the minimum value is 0 for the peasants are class we have from the values

06:49.770 --> 06:50.490
1 2 3.

06:50.490 --> 06:58.170
So the minimum value is 1 for the sixth column we have female and male and female it comes alphabetically

06:58.170 --> 06:58.990
reform males.

06:59.000 --> 07:05.820
So we have female and the youngest passenger on the Titanic was only 0 point for 2 years old and the

07:05.830 --> 07:10.860
passengers who didn't have any brothers sisters or spouses aboard.

07:10.890 --> 07:18.270
And also the passengers who didn't have any terminal parents onboard and lots of passengers who actually

07:18.510 --> 07:22.030
didn't pay any fares so the ferries 0.

07:22.180 --> 07:28.810
And if you compare here the min method with our bid and function men here then we see the power of the

07:28.810 --> 07:34.750
pen data frame class cost by applying the min method them Panda's returns less than the minimum for

07:34.750 --> 07:35.440
each column.

07:35.440 --> 07:36.520
So that's quite cool.

07:37.300 --> 07:43.150
So the main method is specifically defined for a data frame and gives us much more functionality and

07:43.150 --> 07:47.630
tells us much more than the pacing function.

07:47.740 --> 07:54.340
So this is what I wanted to show you that out of the data frame class is very powerful and we can also

07:54.340 --> 08:01.360
have a look here at the documentation so you can see a description of pen that Ida frames so it's a

08:01.360 --> 08:07.740
two dimensional size mutable a potentially heterogeneous tabular data structure mislabeled axis and

08:07.740 --> 08:11.920
t you can find actually all attributes and all methods.

08:11.950 --> 08:14.050
So it's quite a long list here

08:16.910 --> 08:19.310
then in the next the lessons and in our.

08:19.340 --> 08:24.950
We will have a look at many of these methods and learn a lot of functionalities so hope to see on the

08:24.950 --> 08:26.030
next lessons by.
