WEBVTT

00:00.680 --> 00:06.290
In this video we learn how to add a brand new column to our data frame so later and the cost.

00:06.290 --> 00:12.590
And there's a complete section about concatenate emerging and joining off data friends and as areas.

00:12.590 --> 00:17.710
So this video is meant to be a short introduction to this topic.

00:17.740 --> 00:26.290
All right so let's first import pandas and we also import our Titanic's dataset and we have a look at

00:26.290 --> 00:32.940
the first five rows and now we want to create a brand new column with only one value so all of those

00:32.940 --> 00:39.420
have the same value and we can do this with the so-called broadcasting.

00:39.420 --> 00:43.740
And let's assume that the column should only have zeros on all rows as a zero.

00:44.160 --> 00:51.380
And we want to call our columns the rows so the labels should be zeros and what we first can do what

00:51.380 --> 00:58.070
we can actually select a column by passing the column in quotation marks within this span brackets here

00:58.670 --> 01:05.130
and let's check if we have already a column zero so I would guess that we get an error here.

01:06.660 --> 01:08.940
So there is no zeros as column label.

01:10.050 --> 01:15.910
And what we can do now we can create a new column called zeroes and we can assign a value.

01:15.960 --> 01:18.180
And that's zero here.

01:18.270 --> 01:20.700
So let's see what we get.

01:20.700 --> 01:22.790
So let's have a look here at our data frame.

01:24.670 --> 01:32.390
And here we can see on the right side of that there is a new column with the label zeros and the values

01:32.480 --> 01:39.130
0 and it's actually not necessary to have a integer offload as new value.

01:39.130 --> 01:45.640
We can also pass here a string 0 and let's check again.

01:45.640 --> 01:53.590
So now we overwrite the existing is that row column here and now we have our and use the row column

01:53.710 --> 02:01.390
with them the values the row as a string before we learn that we can select a single column either by

02:01.390 --> 02:11.530
the spec records notation here or by calling the attribute here and both notations are when selecting

02:11.530 --> 02:13.300
single columns are the same.

02:13.360 --> 02:17.640
And now it comes at the most important difference between those two notations.

02:18.640 --> 02:24.850
So with the span brackets notation b not only can select an existing column we can also create a new

02:24.850 --> 02:27.580
column as you see here.

02:27.730 --> 02:35.040
However with them the attribute notation we only can select existing columns so we cannot create new

02:35.040 --> 02:43.690
columns however we can try to do so and we could try to create a column once with the one as a value

02:45.590 --> 02:50.180
and we can have a look at our data frame.

02:50.180 --> 02:58.920
And obviously there is no column with the label ones and the values one however we can call the attribute

02:58.920 --> 03:03.650
1 so maybe something is uh saved here.

03:03.730 --> 03:09.630
Yeah and actually we created the attribute once and that's just a single value of one.

03:10.620 --> 03:16.470
So far the class Panda's data frame we created an attribute once and we assign the value one.

03:16.530 --> 03:21.080
But actually we didn't create a brand new column.

03:21.140 --> 03:21.590
All right.

03:21.590 --> 03:25.790
So now we are finished with this session and I hope to see you in the next session by.
