Python tutorial - 2 Ways to Remove Negative Values from Lists

Поделиться
HTML-код
  • Опубликовано: 19 янв 2025

Комментарии • 10

  • @lynnajema9332
    @lynnajema9332 2 года назад

    Hello came across this video while looking for a video explaining how to remove negative 1(-1) in a dataframe. Any ideas? i will really appreciate

  • @tonymichaels8673
    @tonymichaels8673 4 года назад

    Thanks. This was useful

  • @arnavkonda1746
    @arnavkonda1746 3 года назад

    Would you be able to do this with recursion? If so, how?

    • @BrendanMetcalfe
      @BrendanMetcalfe  3 года назад

      No idea man 😂

    • @arnavkonda1746
      @arnavkonda1746 3 года назад

      @@BrendanMetcalfe lol yea i think i figured it out. I ended up creating a list inside the function and and appending the min values if they were less than zero, and then returning the length of the list. I don't know why my teacher wanted me to do it this way but at least I got it ig

  • @АтаРозыев-ы8з
    @АтаРозыев-ы8з 4 года назад

    How to replace negative numbers to their indexes using Lambda function?

    • @BrendanMetcalfe
      @BrendanMetcalfe  4 года назад

      If you mean converting, say, -5 to 5, use the abs() built-in function

    • @АтаРозыев-ы8з
      @АтаРозыев-ы8з 4 года назад

      @@BrendanMetcalfe no, I mean there's a list with numbers [0,2,-4,5,-7,-11,3] and my task is to replace all the negatives to their numbers in a list so it will look like [0,2,2,5,4,5,3]

    • @BrendanMetcalfe
      @BrendanMetcalfe  4 года назад

      @@АтаРозыев-ы8з Yes I understand.. use the abs() function and and an if statement stackoverflow.com/questions/1585322/is-there-a-way-to-perform-if-in-pythons-lambda

    • @АтаРозыев-ы8з
      @АтаРозыев-ы8з 4 года назад

      @@BrendanMetcalfe thank you sir!) You are the best🔥