Skip to player
Skip to main content
Skip to footer
Search
Connect
Recommended
11:25
|
Up next
Pandas Class 08: Changing Data in Pandas – Replace & Update
Nafees AI Lab
5/28/2025
6:59
Pandas Class 05: Describing & Summarizing Data in Pandas
Nafees AI Lab
5/26/2025
14:15
Pandas Class 07: More on Data Selection in Pandas
Nafees AI Lab
5/28/2025
10:09
Pandas Class 03 – Understanding DataFrames in Pandas
Nafees AI Lab
5/26/2025
13:58
Pandas Class 06: Data Selection in Pandas – iloc & loc
Nafees AI Lab
5/28/2025
10:08
Pandas Class 10: Manipulating Data – Sorting, Renaming & More
Nafees AI Lab
5/28/2025
3:06
Pandas Class 02 – What is Pandas & Course Overview
Nafees AI Lab
5/26/2025
5:36
Pandas Class 01 – Tools Needed to Start Data Analysis
Nafees AI Lab
5/26/2025
7:00
Pandas Class 04 – How to Import CSV, Excel & JSON Files
Nafees AI Lab
5/26/2025
7:03
How to get absolute value using abs() method and pandas
Jit Dutta
4/12/2023
9:38
Episode 1 – The Curious Boy from Ulm (1879-1895)
Nafees AI Lab
6/8/2025
0:37
Top Fully Funded Scholarships in Germany 2025 🇩🇪 | Apply Now!
Nafees AI Lab
6/3/2025
0:25
The Boy and the Dragon – “A Friend in the Sky”
Nafees AI Lab
6/3/2025
1:03
Why Do Rainbows Appear? 🌈 | Physics in Everyday Life
Nafees AI Lab
6/3/2025
0:28
Albert Einstein: The Genius Who Changed Time
Nafees AI Lab
6/1/2025
0:40
Stephen Hawking’s Life in 60 Seconds: From Wheelchair to the Universe
Nafees AI Lab
6/1/2025
0:36
The Forgotten Night Hitler Was Nearly Killed
Nafees AI Lab
5/29/2025
0:31
Dilip Kumar – The Tragedy King of Bollywood
Nafees AI Lab
5/29/2025
0:45
Marlon Brando – The Rebel Who Redefined Acting | Nafees AI Lab
Nafees AI Lab
5/29/2025
0:29
Charles Darwin – Evolution & Natural Selection | Nafees AI Lab
Nafees AI Lab
5/28/2025
0:30
Isaac Newton – Gravity, Motion & Genius | Nafees AI Lab
Nafees AI Lab
5/28/2025
0:52
Allama Iqbal – Poet of the East | Nafees AI Lab
Nafees AI Lab
5/28/2025
0:53
Marie Curie – Life & Achievements | Nafees AI Lab
Nafees AI Lab
5/28/2025
0:42
Albert Einstein – Life, Legacy & Discoveries | Nafees AI Lab
Nafees AI Lab
5/28/2025
4:01
ML Class 12: Summary of All Lessons
Nafees AI Lab
5/25/2025
Watch fullscreen
Like
Comments
Bookmark
Share
Add to Playlist
Report
Pandas Class 09: Adding & Removing Data in Pandas
Nafees AI Lab
Follow
5/28/2025
Easily add new columns or remove data from your dataset in Pandas.
#AddRemoveData #DataCleaning #PythonData
Category
📚
Learning
Transcript
Display full video transcript
00:00
data manipulation की discussion को आगे बढ़ाते हैं
00:02
और data manipulation के अवाले से
00:04
इस lecture के अंदर हम लोग तीन चीज़ें सीखने लगे हैं
00:07
पहली चीज तो यह है किस तरीके से
00:09
आप एक column add कर सकते हैं
00:11
existing table के अंदर
00:12
दूसरी चीज हम यह सीखेंगे किस तरीके से
00:15
आप एक column को remove कर सकते हैं
00:17
और तीसरा अगर एक column की values
00:19
change करनी हो तो वो कैसे होगा तो चलिए सब से पहले
00:21
तो हम add से शुरू करते हैं
00:23
अच्छा एक चीज़ा आपने अपने जहन में रखनी है कि
00:25
अगर यह देखिए मैं यहाँ पर variable call करता हूँ
00:27
तो यह मुझे error देगा और उसकी reason
00:29
मैंने शायद पहले भी बताई हो कि एक दफर जब आप
00:31
जब आप जुपिटर नोटबुक को close करके दोबारा open करते हैं
00:33
तो variable की values जो हैं वो lose हो जाती है
00:35
तो इसलिए हम इसको दोबारा load करने लगए
00:37
तो pd.read underscore csv करते हैं
00:41
और इसके अंदर जो है
00:43
मैं string के अंदर दूँगा
00:45
clean data जो csv file last time हमने save की थी
00:47
इसी को ही उठा लेते हैं
00:49
ठीक है मैं इसको execute करता हूँ
00:51
as you see हमारे पास जो है pd
00:53
आ रहा है error क्योंकि मैंने
00:56
इस cell को execute करना है
00:57
ठीक है अब नीचे आते हैं और
00:59
हम मैं run करता हूँ
01:01
तो अब हमारे पास clean data आ गया हुआ
01:03
मैं यहां पे इसको copy paste करके execute करते हैं
01:06
तो यह देखे हमारे पास यह data table है
01:08
जिसके अंदर five entries पड़ी हुई है
01:10
सबसे पहले अगर आपने इसके अंदर कोई नया column add करना हो
01:14
तो उसकी example ऐसे ही है
01:16
जैसे कोई column को change करना हो
01:18
ठीक है by default अगर वो column exist नहीं करता है
01:21
तो new create हो जाता है
01:22
अगर exist करता है
01:23
तो existing के अंदर change आ जाती है
01:25
तो यह काम तो हम पहले कहें ना
01:26
मिसाल के तोर पे मैं अगर इस तरह कहता हूँ
01:28
के एक नया column है
01:29
let's say
01:29
मैं नया column का नाम रख लेते हैं
01:33
और नाम को रखता हूँ let's say battery
01:36
battery ठीक है
01:38
और battery को मैं कोई value assign करने लगा हूँ
01:42
ठीक है
01:42
और let's suppose के इस battery को जो मैं value assign करने लगा हूँ
01:47
वो मैं create करूँगा एक series से
01:50
अब series तो हमने already create की थी ना last time
01:54
तो मैं दुबारा करी लगा हूँ
01:56
B A T T R I S batteries is equal to P D dot S E R I S series
02:01
अब इस series के अंदर मैं let's say number of batteries देने लगा हूँ
02:05
और वो हैं जी let's say
02:07
3, 4, 3, 5 and 7
02:10
ठीक है
02:11
तो ये मैंने batteries डाल दी है
02:13
ठीक है
02:13
और batteries डाल दी है
02:14
ठीक है
02:15
और अब basically मैं ये जो batteries है ना
02:19
ये add कर सकता हूँ
02:21
इस column के अंदर
02:23
अब एक नया column create होगा
02:25
और उस column की जो values होंगी
02:27
वो ये batteries को मैंने दी हैं जो
02:29
वो assign हो जाएंगी
02:30
तो मैं cell को execute करता हूँ
02:31
और phone.csv दोबारा मैं आपको यहां पे दिखाता हूँ
02:34
देखते हैं क्या है
02:35
control V, control C
02:37
अब जर आप गोर करें
02:38
कि battery जो है यहां पे add हो गया हो है
02:40
batteries का एक नया column
02:42
ठीक है
02:43
however आपने एक चीज़ नोट की
02:45
कि total number of entries जो थी
02:47
वो six थी
02:48
लेकिन जो value मैंने दी
02:50
वो value मैंने five दी
02:52
तो इसलिए जो value missing थी
02:54
वहां पे nan value आगे हुई है
02:57
ठीक है
02:57
अच्छा
02:58
अब
02:59
of course हमने यह सीखा हुआ है
03:01
कि nan value को कैसे remove करते हैं
03:04
यह तो हमें पता है ना
03:05
तो
03:05
इसी column को आपने पकड़ना है
03:07
ठीक है
03:07
इसी column को
03:08
और आपने कहना है कि यार यही जो column है ना
03:11
इसको fill na function डाल दो इसके ओपर
03:15
fill na
03:16
और fill na को कहो कि कौन सी value
03:19
जो na पे आ रही है
03:21
उस value को किस value से replace करना है
03:25
let's say मैं कहता हूँ five replace करना है
03:28
और उसके बाद अगर आपको मैंने बताया था कि
03:33
देखें अगर मैं यह ऐसे execute कर देता हूँ ना
03:37
तो value में change आएगी
03:39
however original table के अंदर change reflect नहीं होगी
03:41
इसलिए हमें in place is equal to true करना पड़ता है
03:44
तो मैं in place is equal to true already यहाँ पर कर देता हूँ
03:48
तो अब मैं जो change करूँगा
03:50
वो basically आप देखेंगे कि यह nan जो है वो remove हो जाएगा
03:53
तो चलिए इसको test करता है
03:54
मैं इसको execute करता हूँ
03:55
और again मैं phone underscore csv को यहाँ पर call करता हूँ
03:59
run करते हैं
04:01
अब run करते हैं
04:02
आप देखिए कि उस nan की जगा पे
04:04
अगर आप गोर करें यह nan है
04:06
ठीक है जब हमने यह fill na run किया
04:09
तो उसने na n के जगा 5 डाल दिया
04:11
क्योंकि हमने इसको का था कि
04:12
आपने 5 value को replace करना है
04:14
very good
04:15
तो एक method हमने सीख लिया
04:17
एक नए column को create करने का
04:20
ऐसा ही है ना
04:21
अच्छा अब मैं आपको एक interesting चीज दिखाता हूँ
04:24
आप थोड़ा से देख के हैरान भी होंगे और परिशान भी होंगे
04:26
हमने अपने python के course के अंदर
04:30
lists के बारे में सीखा था
04:32
तो मैं इस तरह करता हूँ के
04:36
एक feature add करता हूँ ringtone
04:38
ठीक है ringtones
04:40
एक ringtones है
04:41
और उस ringtone के अंदर जो है
04:44
let's say number of ringtones है
04:46
हर phone के अंदर number of ringtones है
04:48
लेकिन यह जो ringtones है
04:50
यह एक python list है
04:51
ठीक है एक python list है
04:54
जिसके अंदर number of ringtones पड़ी हुई है
04:56
तो मैं कोई random number of ringtones देने लगा हूँ
04:58
let's say one
04:59
five six eight seven
05:02
let's say this much
05:06
ठीक है
05:08
अच्छे यह कोई random है
05:09
मैंने को count नहीं किया कि कितनी
05:12
ringtones है ठीक है
05:13
अब जर आपने गहुर करना है
05:16
यह one को मैं यहां से remove कर देता हूँ
05:18
ठीक है
05:18
अब number of ringtones हमारे पास है
05:22
as a list
05:23
अब जर आपने गहुर करना है
05:24
मैं एक नया column create करने लगा हूँ
05:27
ठीक है
05:27
और उस column को हम कहते हैं
05:29
कि जी ringtones
05:30
ringtones
05:32
और ringtones
05:34
is equal to
05:35
हमारी यह जो python list है
05:38
ठीक है यह देखे
05:39
अच्छा मैं इसको execute करता हूँ
05:42
however
05:43
यह हमें error दे रहा है
05:44
और अगर आप थोड़ा सा error को गोर से पढ़ें
05:47
बाइदबे यह error यहां से पढ़ना होता है आपने
05:49
तो वो कह रहा है कि length of value
05:51
do not match the length of index
05:53
तो इसका मतलब यह है कि
05:55
इसके अंदर entries है ना
05:58
यह entries है
05:59
1, 2, 3, 4, 5 and 6 entries
06:02
1, 2, 3, 4, 5
06:05
तो वो यह कह रहा है कि
06:07
भाई
06:08
जितनी entries आपके table में है
06:12
exactly
06:12
उतनी ही entries list के अंदर होनी चाहिए
06:16
अगर आप
06:17
एक नया column create करना चाहते हैं तो
06:19
तो यह आपने फर्क देखना है
06:21
कि series के अंदर आपको
06:23
dimension mismatch problem
06:26
नहीं आता
06:27
however जब आप list के लिए डालते हैं
06:29
जो python simple list यूज़ करते हैं
06:31
तो उसमें dimension का exact होना बहुत जरूरी है
06:33
अगर dimension mismatch होगी
06:35
तो आपको error आएगा
06:36
यह चीज़ आपने अपने जहन में रखनी है
06:38
ठीक है
06:39
तो अगर यहीं पर एक और value डालते हैं
06:43
हमें पता है
06:43
यह five values हैं already
06:44
मैं एक और value डालता हूँ
06:45
अब इसको execute करते हैं
06:48
अब यह बिल्कुल perfectly execute हो गया हुए
06:50
और आप देखेंगे कि नया
06:51
ringtones का column आपके पास create हो गया हुए
06:54
as you can see here
06:55
ठीक है
06:56
ठीक है तो चले आगे चलते हैं
07:00
अब हमने दो काम किये
07:02
हमने एक नया column create किया
07:04
अब आप एक column को
07:14
existing column से भी create कर सकते हैं
07:17
very interesting
07:18
तो चलिए मैं इस तरह करता हूँ
07:20
कि एक नया column create करते हैं
07:22
और उस column के खासियत यह होगी
07:23
कि वो column battery और ringtone का product होगा
07:27
battery और ringtone का product होगा
07:31
वो कैसे करेंगे
07:32
अब जब आपने गोर करना है
07:34
ये देखिये ये मेरे पास है
07:35
phone का data
07:36
भीड़िवा है
07:37
phone data है मेरे पास
07:38
अब इस phone का
07:41
जो मैंने
07:42
column change करना है
07:44
वो column उठाता हूँ
07:46
ठीक है
07:47
और
07:48
let's say
07:49
मैंने इसको जिस column के साथ
07:51
change करना है
07:52
मैं वो column उठाता हूँ
07:53
तो मैं इसको इसको इसको ही पक्ड़के ना
07:55
control c multiply control v ringtone control c and this operation I will assign one third
08:05
column I am going to assign one third column and I am going to control c and this one is
08:17
let's say product is equal to phone csv these are two columns which I am going to assign one third column
08:30
I am going to execute it and now we will see the phone csv and what is the new column added
08:35
as you can see that this product is displayed here and product is 1,3,3,2,4,8,5,5,25 and so on
08:46
this was the same thing that if you operation and do existing columns you can create a column
08:53
then you can create a single value as well as you can create a column that is how we can do it
08:58
for example we will see this column and this one is the same thing and this one is the same thing
09:01
I am going to say product csv and I am going to say new underscore column and new column is equal to
09:07
three now I am going to execute it so I am going to say new column is the same thing that
09:12
is the same thing that I am going to do it this is very cool huh
09:19
this is very cool huh
09:21
this is very cool huh
09:24
this is very cool
09:27
this is very cool
09:29
is very cool huh
09:30
this is very cool and back
09:32
you can hear it
09:36
this is very cool huh
09:38
this is very cool
09:39
I am going to call the say
09:40
let's say
09:41
safety
09:42
battery safety
09:43
safety, battery safety, and I will assign a boolean value to true.
09:48
So I will execute this.
09:50
You can see that we have again a boole column created,
09:54
which is true.
09:56
And if you run the D-type function,
09:59
you will explain that it will be D, T, Y, P, E, S, D-type.
10:02
Execute.
10:03
You can see that you have a safety boolean function created,
10:08
because we have created boolean function.
10:11
This is how to create columns and different operations.
10:17
If we remove the column, it will be very easy.
10:24
We use the drop command.
10:27
This is the table.
10:30
We have drop call.
10:32
Drop call.
10:35
I will drop a new column.
10:38
Ctrl-C.
10:39
And here I will say, new column we have dropped.
10:44
However, this information is not complete.
10:48
If you remember, when I had to tell you,
10:50
when I had to tell you that I had to tell you that I had two things.
10:56
I said that a table is rows and columns.
11:00
I have to tell you,
11:02
that I have one column.
11:04
اسی طرح میں نے یہ کہا تھا
11:06
کہ جو horizontal direction میں آپ کو
11:08
data نظر آ رہا ہے
11:09
مثال کے طور پر
11:09
ایک table
11:10
ایک line لے رہا ہوں میں
11:12
تو یہ جو ساری line ہے
11:14
یہ ایک single row ہے
11:16
ایسا ہی ہے نا
11:17
اب میں نے یہ کہا تھا
11:18
کہ یار یہ جو column ہوتا ہے نا
11:20
اس کو axis is equal to one
11:22
سے represent کرتے ہیں
11:23
اور جو row ہے
11:24
اس کو axis is equal to zero
11:25
سے represent کرتے ہیں
11:26
تو اب میں جب بھی drop کرنی ہوتی ہے نا
11:29
values تو آپ نے بتانا ہوتا ہے
11:30
کہ یار میں نے row drop کرنی ہے
11:32
یا column drop کرنا ہے
11:33
تو اس کے اس میں کیوں کہ
11:35
ہم نے column drop کرنا ہے
11:36
تو اس لیے میں drop کو آکے
11:38
ایک extra information دوں گا
11:39
اور کہوں گا
11:40
axis is equal to one
11:43
تو axis is equal to one کا مطلب ہے
11:45
کہ column drop کرنا
11:46
اور column کا نام ہے new column
11:48
تو چلیئے اس کو execute کرتے ہیں
11:50
اب ذرا آپ نے غور کرنا ہے
11:52
کہ میں assignment نہیں کر رہا ہوں یہاں پہ
11:54
تو دو طریقے ہیں
11:55
یا تو میں اس کو ایک نئے
11:57
اس کو ایسے reassign کروں
11:59
ٹھیک ہے
12:00
اسے کروں
12:01
یا پھر
12:02
یا پھر اگر میں یہ نہیں کرنا چاہتا
12:06
تو یہیں پہ میں کر سکتا ہوں
12:08
in
12:08
place is equal to true
12:12
however you like
12:13
تو میں اس کو execute کرتا ہوں
12:15
اور phone.csv کو
12:16
آپ کو سامنے لے کے آتا ہوں
12:18
دکھاتے ہیں جی
12:19
تو آپ دیکھئے کہ
12:20
آپ کے پاس جو new column ہے
12:21
وہ remove ہو گیا ہوا ہے
12:23
آپ کو یہاں پہ new column
12:24
جو ہے وہ نظر نہیں آ رہا
12:26
تو یہاں پہ اس lecture کو کرتے ہیں
12:28
closed seat
Recommended
11:25
|
Up next
Pandas Class 08: Changing Data in Pandas – Replace & Update
Nafees AI Lab
5/28/2025
6:59
Pandas Class 05: Describing & Summarizing Data in Pandas
Nafees AI Lab
5/26/2025
14:15
Pandas Class 07: More on Data Selection in Pandas
Nafees AI Lab
5/28/2025
10:09
Pandas Class 03 – Understanding DataFrames in Pandas
Nafees AI Lab
5/26/2025
13:58
Pandas Class 06: Data Selection in Pandas – iloc & loc
Nafees AI Lab
5/28/2025
10:08
Pandas Class 10: Manipulating Data – Sorting, Renaming & More
Nafees AI Lab
5/28/2025
3:06
Pandas Class 02 – What is Pandas & Course Overview
Nafees AI Lab
5/26/2025
5:36
Pandas Class 01 – Tools Needed to Start Data Analysis
Nafees AI Lab
5/26/2025
7:00
Pandas Class 04 – How to Import CSV, Excel & JSON Files
Nafees AI Lab
5/26/2025
7:03
How to get absolute value using abs() method and pandas
Jit Dutta
4/12/2023
9:38
Episode 1 – The Curious Boy from Ulm (1879-1895)
Nafees AI Lab
6/8/2025
0:37
Top Fully Funded Scholarships in Germany 2025 🇩🇪 | Apply Now!
Nafees AI Lab
6/3/2025
0:25
The Boy and the Dragon – “A Friend in the Sky”
Nafees AI Lab
6/3/2025
1:03
Why Do Rainbows Appear? 🌈 | Physics in Everyday Life
Nafees AI Lab
6/3/2025
0:28
Albert Einstein: The Genius Who Changed Time
Nafees AI Lab
6/1/2025
0:40
Stephen Hawking’s Life in 60 Seconds: From Wheelchair to the Universe
Nafees AI Lab
6/1/2025
0:36
The Forgotten Night Hitler Was Nearly Killed
Nafees AI Lab
5/29/2025
0:31
Dilip Kumar – The Tragedy King of Bollywood
Nafees AI Lab
5/29/2025
0:45
Marlon Brando – The Rebel Who Redefined Acting | Nafees AI Lab
Nafees AI Lab
5/29/2025
0:29
Charles Darwin – Evolution & Natural Selection | Nafees AI Lab
Nafees AI Lab
5/28/2025
0:30
Isaac Newton – Gravity, Motion & Genius | Nafees AI Lab
Nafees AI Lab
5/28/2025
0:52
Allama Iqbal – Poet of the East | Nafees AI Lab
Nafees AI Lab
5/28/2025
0:53
Marie Curie – Life & Achievements | Nafees AI Lab
Nafees AI Lab
5/28/2025
0:42
Albert Einstein – Life, Legacy & Discoveries | Nafees AI Lab
Nafees AI Lab
5/28/2025
4:01
ML Class 12: Summary of All Lessons
Nafees AI Lab
5/25/2025