Understanding (and avoiding) the SettingWithCopyWarning in Pandas

  Рет қаралды 4,414

Python and Pandas with Reuven Lerner

Python and Pandas with Reuven Lerner

Күн бұрын

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/reu.... And don't forget my free, weekly "Better developers" newsletter at BetterDevelope...!

Пікірлер
@cstephens16
@cstephens16 2 жыл бұрын
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 2 жыл бұрын
Thanks so much!
@aflous
@aflous 2 жыл бұрын
This is by far the best explanation I've ever seen for this issue 🤩
@ReuvenLerner
@ReuvenLerner 2 жыл бұрын
Glad you enjoyed it, thanks for the kind words!
@_truthful_q_
@_truthful_q_ 2 жыл бұрын
Nice video, thanks Reuven! The why is just as important as the how 🙂
@ReuvenLerner
@ReuvenLerner 2 жыл бұрын
My pleasure!
@tomkmb4120
@tomkmb4120 5 ай бұрын
Great video Reuven, this warning always boils my blood lol
@ReuvenLerner
@ReuvenLerner 5 ай бұрын
Excellent, I'm glad that it helped!
@TheCJD89
@TheCJD89 2 жыл бұрын
Great explanation. This problem happens so, so often! :D
@ReuvenLerner
@ReuvenLerner 2 жыл бұрын
You're not alone; glad this helped!
@DookyButter
@DookyButter 2 жыл бұрын
Best explanation I've seen so far and under 10 min! Thank you because I absolutely loathe that error.
@ReuvenLerner
@ReuvenLerner 2 жыл бұрын
Thanks for the kind words; I'm glad you enjoyed it! (And yeah, that error is the worst...)
@KevinBurns
@KevinBurns 2 жыл бұрын
Great overview Reuven and something I have fallen into a number of times when working in Pandas 😀
@ReuvenLerner
@ReuvenLerner 2 жыл бұрын
You're not alone! Glad to hear it helped.
@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!
@shadrinan90
@shadrinan90 6 ай бұрын
Great explanation, thanks!
@ReuvenLerner
@ReuvenLerner 6 ай бұрын
I'm delighted it helped!
@RenatoCosta1
@RenatoCosta1 2 жыл бұрын
Crystal clear explanation! Thank you very much for that!
@ReuvenLerner
@ReuvenLerner 2 жыл бұрын
Delighted to know you enjoyed!
@horoshuhin
@horoshuhin 2 жыл бұрын
that's a good one. like always excellent explanation. thanks
@ReuvenLerner
@ReuvenLerner 2 жыл бұрын
Glad you enjoyed it!
@vincentcrescente3036
@vincentcrescente3036 2 жыл бұрын
Awesome, thanks man
@ReuvenLerner
@ReuvenLerner 2 жыл бұрын
Glad it helped!
@somethingness
@somethingness 2 жыл бұрын
This was great. Thank you!
@ReuvenLerner
@ReuvenLerner 2 жыл бұрын
Glad you enjoyed it!
@minhdzung
@minhdzung Жыл бұрын
Thank you sir!
@videotape-
@videotape- Жыл бұрын
sir, you are great!
@ReuvenLerner
@ReuvenLerner Жыл бұрын
Thanks so much for the kind words!
@mosama22
@mosama22 10 ай бұрын
Man, I “LOVE” you …..
@ReuvenLerner
@ReuvenLerner 10 ай бұрын
Thanks so much! You have no idea how much this kind of comment means to me.
@mattp6460
@mattp6460 11 ай бұрын
amazing thanks
@ReuvenLerner
@ReuvenLerner 11 ай бұрын
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?
@albertjimenez6605
@albertjimenez6605 Жыл бұрын
Mil gracias! Tienes un nuevo subs.
@ReuvenLerner
@ReuvenLerner Жыл бұрын
Delighted that you enjoyed it!
@codeministry
@codeministry Жыл бұрын
Best explanation for human
@ReuvenLerner
@ReuvenLerner Жыл бұрын
Glad to know it helped!
@tanzinabinteyousuf6184
@tanzinabinteyousuf6184 Жыл бұрын
what if i fix it still the warning shows. what should i do?
@ReuvenLerner
@ReuvenLerner Жыл бұрын
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 Жыл бұрын
@@ReuvenLerner thanks for your response. i had issue with two lines. fixed both the line and the warning finally went off.
@tizianrettig5509
@tizianrettig5509 Жыл бұрын
This just does not apply to the issue si am seeing.
@ReuvenLerner
@ReuvenLerner Жыл бұрын
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
Рет қаралды 45 М.
How do I avoid a SettingWithCopyWarning in pandas?
13:30
Data School
Рет қаралды 45 М.
coco在求救? #小丑 #天使 #shorts
00:29
好人小丑
Рет қаралды 120 МЛН
What does "if __name__ == '__main__' " do in Python?
14:03
Python and Pandas with Reuven Lerner
Рет қаралды 6 М.
Basic grouping in pandas
8:09
Python and Pandas with Reuven Lerner
Рет қаралды 4 М.
Retrieving from a multi-index in Pandas
11:58
Python and Pandas with Reuven Lerner
Рет қаралды 4,4 М.
Speed Up Your Pandas Dataframes
11:15
Rob Mulla
Рет қаралды 73 М.
1000x faster data manipulation: vectorizing with Pandas and Numpy
26:39
How do I handle missing values in pandas?
14:28
Data School
Рет қаралды 198 М.
Turn numbers into categories with the Pandas "cut" method
9:44
Python and Pandas with Reuven Lerner
Рет қаралды 6 М.
How do I merge DataFrames in pandas?
21:49
Data School
Рет қаралды 159 М.
25 Nooby Pandas Coding Mistakes You Should NEVER make.
11:30
Rob Mulla
Рет қаралды 282 М.
What do I need to know about the pandas index? (Part 1)
13:37
Data School
Рет қаралды 135 М.
coco在求救? #小丑 #天使 #shorts
00:29
好人小丑
Рет қаралды 120 МЛН