Understanding (and avoiding) the SettingWithCopyWarning in Pandas

  Рет қаралды 3,620

Python and Pandas with Reuven Lerner

Python and Pandas with Reuven Lerner

2 жыл бұрын

Just about everyone using Pandas for data analytics encounters the SettingWithCopyWarning. What does it mean? How does it happen? And how can we avoid it? In this video, I explain all of these things, including how to fix the problem if and when you encounter it.
The Jupyter notebook for all of my videos are at github.com/reuven/youTube-not.... And don't forget my free, weekly "Better developers" newsletter at BetterDevelopersWeekly.com/!

Пікірлер: 41
@cstephens16
@cstephens16 Жыл бұрын
This was the best explanation for that warning i have ever come across. can't wait for you pandas workout book to come out.
@ReuvenLerner
@ReuvenLerner Жыл бұрын
Thanks so much!
@aflous
@aflous Жыл бұрын
This is by far the best explanation I've ever seen for this issue 🤩
@ReuvenLerner
@ReuvenLerner Жыл бұрын
Glad you enjoyed it, thanks for the kind words!
@_truthful_q_
@_truthful_q_ Жыл бұрын
Nice video, thanks Reuven! The why is just as important as the how 🙂
@ReuvenLerner
@ReuvenLerner Жыл бұрын
My pleasure!
@TheCJD89
@TheCJD89 Жыл бұрын
Great explanation. This problem happens so, so often! :D
@ReuvenLerner
@ReuvenLerner Жыл бұрын
You're not alone; glad this helped!
@DookyButter
@DookyButter Жыл бұрын
Best explanation I've seen so far and under 10 min! Thank you because I absolutely loathe that error.
@ReuvenLerner
@ReuvenLerner Жыл бұрын
Thanks for the kind words; I'm glad you enjoyed it! (And yeah, that error is the worst...)
@KevinBurns
@KevinBurns Жыл бұрын
Great overview Reuven and something I have fallen into a number of times when working in Pandas 😀
@ReuvenLerner
@ReuvenLerner Жыл бұрын
You're not alone! Glad to hear it helped.
@mosama22
@mosama22 3 ай бұрын
Man, I “LOVE” you …..
@ReuvenLerner
@ReuvenLerner 3 ай бұрын
Thanks so much! You have no idea how much this kind of comment means to me.
@somethingness
@somethingness Жыл бұрын
This was great. Thank you!
@ReuvenLerner
@ReuvenLerner Жыл бұрын
Glad you enjoyed it!
@minhdzung
@minhdzung 5 ай бұрын
Thank you sir!
@samarthnikhra8827
@samarthnikhra8827 Жыл бұрын
Thank you so much, this explanation was so precise and easy to understand. It helped me a lot. Now I am a subscriber of your channel :)
@ReuvenLerner
@ReuvenLerner Жыл бұрын
Fantastic; I'm delighted to hear it helped!
@RenatoCosta1
@RenatoCosta1 Жыл бұрын
Crystal clear explanation! Thank you very much for that!
@ReuvenLerner
@ReuvenLerner Жыл бұрын
Delighted to know you enjoyed!
@horoshuhin
@horoshuhin Жыл бұрын
that's a good one. like always excellent explanation. thanks
@ReuvenLerner
@ReuvenLerner Жыл бұрын
Glad you enjoyed it!
@vincentcrescente3036
@vincentcrescente3036 Жыл бұрын
Awesome, thanks man
@ReuvenLerner
@ReuvenLerner Жыл бұрын
Glad it helped!
@albertjimenez6605
@albertjimenez6605 Жыл бұрын
Mil gracias! Tienes un nuevo subs.
@ReuvenLerner
@ReuvenLerner Жыл бұрын
Delighted that you enjoyed it!
@videotape-
@videotape- Жыл бұрын
sir, you are great!
@ReuvenLerner
@ReuvenLerner Жыл бұрын
Thanks so much for the kind words!
@codeministry
@codeministry Жыл бұрын
Best explanation for human
@ReuvenLerner
@ReuvenLerner Жыл бұрын
Glad to know it helped!
@mattp6460
@mattp6460 4 ай бұрын
amazing thanks
@ReuvenLerner
@ReuvenLerner 4 ай бұрын
Glad you enjoyed it!
@marcdelabarreraibardalet4754
@marcdelabarreraibardalet4754 Жыл бұрын
Excellent video. But I'm still puzzled by my case. Oversimplifying, I'm trying to do data['y'] = np.log(data['x']) This should bring no warning. The curious thing is that if I do it in a jupyter cell, I don't get a warning. However, I put this inside a function, and I get the SettingWithCopyWarning. Can you think what can be going on? To clarify, the ONLY thing that changes is that this line being inside a function or outside.
@kmayumij
@kmayumij Жыл бұрын
You could rewrite it to: data['y'] = data['x'].apply(lambda x: np.log(x)). This solution will not explain why are you getting that warning, but probably will get rid of the warning.
@ReuvenLerner
@ReuvenLerner Жыл бұрын
Hmm, I'm not sure why you would be getting that, except that (maybe) the data frame is itself a view, or is sharing data with another data frame?
@tanzinabinteyousuf6184
@tanzinabinteyousuf6184 5 ай бұрын
what if i fix it still the warning shows. what should i do?
@ReuvenLerner
@ReuvenLerner 5 ай бұрын
If you have a single set of square brackets and you're still seeing the warning... that's weird! Would you please post your code here? I"ll see if I can understand and help.
@tanzinabinteyousuf6184
@tanzinabinteyousuf6184 5 ай бұрын
@@ReuvenLerner thanks for your response. i had issue with two lines. fixed both the line and the warning finally went off.
@tizianrettig5509
@tizianrettig5509 11 ай бұрын
This just does not apply to the issue si am seeing.
@ReuvenLerner
@ReuvenLerner 11 ай бұрын
Sorry to hear that - I'm guessing that it's a related problem, even if not this precise one.
Pivot tables with Pandas
9:00
Python and Pandas with Reuven Lerner
Рет қаралды 37 М.
The six most important read_csv arguments in Pandas
16:50
Python and Pandas with Reuven Lerner
Рет қаралды 2,7 М.
Nutella bro sis family Challenge 😋
00:31
Mr. Clabik
Рет қаралды 13 МЛН
Understanding "with" and Python's context managers
14:00
Python and Pandas with Reuven Lerner
Рет қаралды 818
How do I avoid a SettingWithCopyWarning in pandas?
13:30
Data School
Рет қаралды 44 М.
Boolean indexing in Pandas made simple
8:23
Python and Pandas with Reuven Lerner
Рет қаралды 1,7 М.
25 Nooby Pandas Coding Mistakes You Should NEVER make.
11:30
Rob Mulla
Рет қаралды 262 М.
Method chaining in Pandas
18:17
Python and Pandas with Reuven Lerner
Рет қаралды 1,8 М.
*args and **kwargs - what are they, and how are they different?
10:42
Python and Pandas with Reuven Lerner
Рет қаралды 1,3 М.
Selecting rows in Pandas using .loc and lambda
9:04
Python and Pandas with Reuven Lerner
Рет қаралды 900
10 Nooby Mistakes Devs Often Make In Python
24:31
Indently
Рет қаралды 52 М.
Flipping Data with Pandas: Stack & Unstack
8:17
Python and Pandas with Reuven Lerner
Рет қаралды 2,5 М.
⚡️Супер БЫСТРАЯ Зарядка | Проверка
1:00
ИГРОВОВЫЙ НОУТ ASUS ЗА 57 тысяч
25:33
Ремонтяш
Рет қаралды 355 М.
Самый дорогой кабель Apple
0:37
Romancev768
Рет қаралды 356 М.