Understanding (and avoiding) the SettingWithCopyWarning in Pandas

แชร์
ฝัง
  • เผยแพร่เมื่อ 9 พ.ย. 2024

ความคิดเห็น • 45

  • @cstephens16
    @cstephens16 2 ปีที่แล้ว +8

    This was the best explanation for that warning i have ever come across. can't wait for you pandas workout book to come out.

  • @aflous
    @aflous 2 ปีที่แล้ว +6

    This is by far the best explanation I've ever seen for this issue 🤩

    • @ReuvenLerner
      @ReuvenLerner  2 ปีที่แล้ว +1

      Glad you enjoyed it, thanks for the kind words!

  • @DookyButter
    @DookyButter 2 ปีที่แล้ว +1

    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 ปีที่แล้ว +1

    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.

  • @_truthful_q_
    @_truthful_q_ 2 ปีที่แล้ว +2

    Nice video, thanks Reuven! The why is just as important as the how 🙂

  • @tomkmb4120
    @tomkmb4120 2 หลายเดือนก่อน +1

    Great video Reuven, this warning always boils my blood lol

    • @ReuvenLerner
      @ReuvenLerner  2 หลายเดือนก่อน

      Excellent, I'm glad that it helped!

  • @TheCJD89
    @TheCJD89 2 ปีที่แล้ว +2

    Great explanation. This problem happens so, so often! :D

    • @ReuvenLerner
      @ReuvenLerner  2 ปีที่แล้ว

      You're not alone; glad this helped!

  • @RenatoCosta1
    @RenatoCosta1 ปีที่แล้ว +1

    Crystal clear explanation! Thank you very much for that!

    • @ReuvenLerner
      @ReuvenLerner  ปีที่แล้ว

      Delighted to know you enjoyed!

  • @shadrinan90
    @shadrinan90 3 หลายเดือนก่อน +1

    Great explanation, thanks!

    • @ReuvenLerner
      @ReuvenLerner  3 หลายเดือนก่อน

      I'm delighted it helped!

  • @samarthnikhra8827
    @samarthnikhra8827 ปีที่แล้ว +1

    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!

  • @somethingness
    @somethingness 2 ปีที่แล้ว +1

    This was great. Thank you!

  • @minhdzung
    @minhdzung 9 หลายเดือนก่อน +1

    Thank you sir!

  • @mosama22
    @mosama22 7 หลายเดือนก่อน +2

    Man, I “LOVE” you …..

    • @ReuvenLerner
      @ReuvenLerner  7 หลายเดือนก่อน

      Thanks so much! You have no idea how much this kind of comment means to me.

  • @horoshuhin
    @horoshuhin 2 ปีที่แล้ว +1

    that's a good one. like always excellent explanation. thanks

  • @vincentcrescente3036
    @vincentcrescente3036 2 ปีที่แล้ว +1

    Awesome, thanks man

  • @marcdelabarreraibardalet4754
    @marcdelabarreraibardalet4754 ปีที่แล้ว +1

    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?

  • @codeministry
    @codeministry ปีที่แล้ว

    Best explanation for human

  • @videotape-
    @videotape- ปีที่แล้ว +1

    sir, you are great!

    • @ReuvenLerner
      @ReuvenLerner  ปีที่แล้ว

      Thanks so much for the kind words!

  • @mattp6460
    @mattp6460 8 หลายเดือนก่อน +1

    amazing thanks

    • @ReuvenLerner
      @ReuvenLerner  8 หลายเดือนก่อน

      Glad you enjoyed it!

  • @albertjimenez6605
    @albertjimenez6605 ปีที่แล้ว +1

    Mil gracias! Tienes un nuevo subs.

    • @ReuvenLerner
      @ReuvenLerner  ปีที่แล้ว +1

      Delighted that you enjoyed it!

  • @tanzinabinteyousuf6184
    @tanzinabinteyousuf6184 9 หลายเดือนก่อน +1

    what if i fix it still the warning shows. what should i do?

    • @ReuvenLerner
      @ReuvenLerner  9 หลายเดือนก่อน

      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 9 หลายเดือนก่อน +1

      @@ReuvenLerner thanks for your response. i had issue with two lines. fixed both the line and the warning finally went off.

  • @tizianrettig5509
    @tizianrettig5509 ปีที่แล้ว +1

    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.