21 more pandas tricks

แชร์
ฝัง
  • เผยแพร่เมื่อ 22 ก.ค. 2024
  • You're about to learn 21 tricks that will help you to work faster, write better pandas code, and impress your friends. These are the BEST tricks that I couldn't fit into my FIRST tricks video!
    📔 JUPYTER NOTEBOOK:
    nbviewer.org/github/justmarkh...
    🔥 MY TOP 25 PANDAS TRICKS:
    • My top 25 pandas tricks
    🐼 MORE PANDAS VIDEOS:
    • Data analysis in Pytho...
    TRICKS:
    0:00 Introduction
    0:36 1. Check for equality
    1:27 2. Check for equality (alternative)
    2:38 3. Use NumPy without importing NumPy
    3:42 4. Calculate memory usage
    4:10 5. Count the number of words in a column
    4:45 6. Convert one set of values to another
    6:59 7. Convert continuous data into categorical data (alternative)
    8:05 8. Create a cross-tabulation
    8:55 9. Create a datetime column from multiple columns
    9:34 10. Resample a datetime column
    11:07 11. Read and write from compressed files
    12:10 12. Fill missing values using interpolation
    12:45 13. Check for duplicate merge keys
    13:50 14. Transpose a wide DataFrame
    14:47 15. Create an example DataFrame (alternative)
    16:06 16. Identify rows that are missing from a DataFrame
    17:09 17. Use query to avoid intermediate variables
    19:06 18. Reshape a DataFrame from wide format to long format
    21:19 19. Reverse row order (alternative)
    22:25 20. Reverse column order (alternative)
    23:21 21. Split a string into multiple columns (alternative)
    NOTE: Tricks 3 and 15 were deprecated in pandas 1.0
    LET'S CONNECT!
    - Newsletter: www.dataschool.io/subscribe/
    - Twitter: / justmarkham
    - Facebook: / datascienceschool
    - LinkedIn: / justmarkham

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

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

    THANKS for watching! 🙌 Which trick are you most excited to start using? CLICK REPLY and let me know!

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

      No. 7 and no 15

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

    That was really Helpful, man! Glad that I saw your tweet in my timeline!

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

      That’s great to hear, thanks Reza! 🙌

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

    love it. I really enjoyed this video. thanks for the quality content

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

      That’s awesome to hear, thank you! 🙏

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

    Thank you so much! Your tutorials are the best

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

      Thank you, Kris! 🙏

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

    What a great video! Thanks!

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

      You’re very welcome!

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

    Thank you for you amazing videos! Super informative and helpful, as always.

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

      That's so nice of you to say! You're very welcome! 🙌

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

    I love these videos. I always learn so much.

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

      What a nice thing to say, thank you so much! 🙏

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

    Even after re-watching them, your videos are outstanding.

    • @dataschool
      @dataschool  6 หลายเดือนก่อน

      Thank you so much! 🙏

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

    Lots of time savers here thanks well done

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

      You're very welcome, Frank!

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

    Thanks a lot for the excellent tricks (25 + 21) ! Really amazing and useful.

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

      You're very welcome! 🙌

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

    excellent as always

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

    Great tips, holy! there is always something new to learn.

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

    I was becoming sad that you were no longer making pandas videos. What a come back like that of Real Madrid :)). Thanks Kevin!!

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

      You are very welcome!

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

    Thanks so much,really helpful

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

      Glad it was helpful to you! 🙌

  • @nothingDone-ei2fj
    @nothingDone-ei2fj 9 หลายเดือนก่อน

    I completed 36 videos in this series. Thanks a lot Kevin for such amazing tutorial.

    • @dataschool
      @dataschool  6 หลายเดือนก่อน +1

      That is awesome to hear! Congratulations!

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

    How to use text classification approach where target column is bigram word...?
    Can you please show us ..?

  • @sheikirfan2652
    @sheikirfan2652 5 หลายเดือนก่อน +1

    Great tutorial ❤

    • @dataschool
      @dataschool  4 หลายเดือนก่อน

      Thank you!

  • @Yuri-to8uj
    @Yuri-to8uj 2 ปีที่แล้ว +1

    amazing content!!

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

    Cool. pandas and numpy seem to have a ton of functions and it’s hard to remember them all. Would appreciate a video focused on multilevel data frames, as I always forget how to index, etc those.

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

      I actually have a video about the MultiIndex! Here it is: th-cam.com/video/tcRGa2soc-c/w-d-xo.html

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

    Great tips and tricks as always!
    do you have a tutorial video about writing efficient pandas code? for example implementing vectorization?
    I've watched plenty of your videos but I think I haven't seen one about the topic

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

      Thanks very much! I think this video might be of interest to you: th-cam.com/video/dPwLlJkSHLo/w-d-xo.html

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

      Awesome, will check that out!

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

    Hi Kevin, Thank you for creating such amazing contents. These videos are really helpful for doing real time projects. I wanted to request you to make video on particular topic. if you can make video on how to use pandas to write, read and edit google sheets, that would be very helpful. It can include putting values in range of cells as well as one cell in google sheet, reading data, etc. If there is already any video you have made on this topic, let me know.

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

      Thanks for your suggestion!

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

    Sir , please make a video on user defined functions in pandas dataframe

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

    Thank you 😊😊

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

      You’re welcome!

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

    I miss your videos , man. Best like to best tutor. 👌

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

    Hi Kevin, Thanks for the insightful video. I love your videos and courses they are so subtle and impactful. Would it be possible for you to make a video on Python Class/objects? Its a daunting concept for someone like me (not from coding background) who has limited understanding of OOPs. Additionally I have observed that many coders use python classes for ML scripts/pipeline, scripting files on Github. So it would be helpful if you could make an video on the same.
    Thanks in advance !!

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

      Thanks for your suggestion! I'll consider it for the future. For now, maybe start here: th-cam.com/play/PL-osiE80TeTsqhIuOqKhwlXsIBIdSeYtc.html
      Hope that helps!

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

    Hi Kevin. The most important question of all: How to remember all of those things? Do you have any means? Any way that lets you retain the tricks/knowledge in your mind for longer? Would you please share any thoughts on that? Thanks.

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

      Great question! I don't have a system for memorization, rather it just comes naturally the more I use something. However, I also don't worry about forgetting, because I usually remember where to look in order to refresh my memory. Thus, my advice is (1) practice, and (2) keep track of good resources so that you can look up things easily whenever you forget. Hope that helps!

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

    Just doing your datacamp RI Police course. It's a really well laid out course and I think you're adorable. :-)

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

    Thanks for the tips.
    Q: How crosstab provided the results compared to pivot where no target value 'Survived' is provided
    Unable to view the Notebook from link provided. Please re upload

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

      Great question! With the pivot table, I just selected a column with no missing values (Survived in this case) and counted them. With crosstab, it automatically does a count, so you don't need to select a specific column.
      Regarding the notebook, you can view it here: github.com/justmarkham/pandas-videos/blob/master/21_more_pandas_tricks.ipynb
      Hope that helps!

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

    why below code is not giving any output
    pd.testing.assert_series_equal(df.c, df.d, check_names=False, check_dtype=False)

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

      Great question! The assertion passed, thus no error was raised, thus no output was generated. If you're new to assertions, just try running assert(1==1) and assert(1==2) in Python, and you'll see that when an assertion passes, there is no output. Hope that helps!

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

    This resample methood is incredibly useful
    Thanks a ton

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

      I agree! It really helped me once I started thinking of resample as a groupby for datetime data.

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

    good

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

    Hi Kevin, I hear a lot about API's. Maybe one day you can demo how to create a basic custom API.

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

      Thanks for your suggestion!

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

    Hi, for example I have a table, which I've got by left outer join:
    person - vehicle
    dad - car
    dad - motorcycle
    dad - bicycle
    mom - car
    mom - bicycle
    son - None/NA/NaN/NaT
    How to group by person and count with condition (car and motorcycle)?
    When I use for example:
    df = df.groupby(['person'])['vehicle'].apply(lambda x: x[x == 'car'].count())
    But I can't use a list in condition lambda x: x[x in ['car']], pandas says:
    ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all()

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

    jupyter notebook link broken

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

      You can use this link instead: github.com/justmarkham/pandas-videos/blob/master/21_more_pandas_tricks.ipynb

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

    The meaning of 🐼 is 46!

  • @user-vd2ui5uk2s
    @user-vd2ui5uk2s ปีที่แล้ว

    Hi Kevin, a question question, why the code (titanix.SibSp > 0).astype(' int ') can set different integers into 0 and 1?

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

      Great question! The boolean value True gets converted to 1, and False gets converted to 0. Hope that helps!

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

    On tips 14, I think a better solution is to use df.style to display all columns and rows of your DataFrame. If you have a lot of rows and are only interested in the columns just use df.head().style

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

      Love it! Thank you for sharing! 🙌