Useful Pandas Snippets

Even after almost two years of working with Pandas, the incredibly useful Python data analysis library, I still need to look up syntax for some common tasks. Finally got around to putting everything on a single “useful Pandas snippets” cheat sheet: these are essential tools for munging federal budget data.

30 Responses to Useful Pandas Snippets

  1. KP November 1, 2014 at 12:18 pm #

    This is awesome! cheers

  2. a November 26, 2014 at 5:20 am #

    great :)

  3. harsha January 6, 2015 at 6:45 pm #

    You just saved me a ton of time!

    Thanks!

  4. b January 19, 2015 at 7:44 am #

    You are now my hero!

    Thanks

  5. b January 19, 2015 at 7:46 am #

    or upon further reading… Heroine

  6. Katharina January 26, 2015 at 7:53 pm #

    Thank you!! Examples are more helpful to me than manuals.

  7. stephan March 3, 2015 at 12:10 pm #

    thanks! very practical

  8. c-trl May 7, 2015 at 4:59 am #

    So glad to learn of some of these! Awesome post :D

  9. Harry May 10, 2015 at 4:27 am #

    I just started with pandas and was planning to use pandas widely. This page is great, but it also scares me that one still needs to lookup common tasks after 2(!) years. The great thing about python had been that “it works as one would expect” and pandas seems to break that.

  10. kotrfa June 4, 2015 at 2:23 pm #

    Great post! Thank you. So long using pandas and almost everything in your post I’ve already knew or was angry that it’s not possible – and it is!

    By the way, ‘del df[“column”]’ for deleting was also new for me and I can’t even express how much it seems unpythonic to me :D . But it is of course a subjective feeling. assert feels same for me too :D

  11. deparkes June 11, 2015 at 6:19 am #

    Really useful – thanks!

  12. Sly August 23, 2015 at 6:44 am #

    your code will not work… you have camel and snake case in examples

  13. Becky August 24, 2015 at 3:37 pm #

    Thanks for stopping by, Sly. If you have a specific example of code that doesn’t work, by all means post it, and I’ll make the fix.

  14. Not Sly August 26, 2015 at 2:06 pm #

    Thank you- this is very useful. @Harry: All programmers, no matter how many years they have been writing code, have to stick their nose in a book every now and then (or more likely, visit StackOverFlow). @Sly: the code will work fine, it’s your manners that do not work.

  15. edoardo October 15, 2015 at 9:02 am #

    This is awesome

  16. spirosmichalak February 24, 2016 at 2:38 am #

    Great! Thanks Becky.

  17. rw June 1, 2016 at 11:17 pm #

    Straight to the point. Cut through tons of reading. You made Pandas easier to use. Thank you for sharing your experience and knowledge on Pandas.

  18. Joel June 19, 2016 at 10:06 am #

    Nice! Thank you.

  19. Monica August 3, 2016 at 11:17 am #

    Quick typo:

    `valuelist = [‘value1′, ‘value2′, ‘value3′]
    df = df[df.column.isin(value_list)]`

    `valuelist` should be spelled `value_list`

  20. Becky August 13, 2016 at 12:48 pm #

    Thank you, Monica, for noticing the typo and taking the time to let me know–much appreciated! I fixed that on the gist.

  21. EOin September 2, 2016 at 1:02 am #

    Hi, your cheat sheet looks as if it will be most useful but the link fails at present (2/Sept 2016).

  22. hari September 19, 2016 at 3:44 am #

    Great post! :)

  23. sridhar September 21, 2016 at 4:01 am #

    Very useful, thanks a lot!

  24. Eddy Barratt September 28, 2016 at 2:25 am #

    Great, thanks!

  25. Ashutosh December 3, 2016 at 12:29 am #

    Thanks a lot!
    I cannot believe the amount of effort I put in to do something you so easily mentioned above.
    This helps a lot

Trackbacks/Pingbacks

  1. hangtwenty/dive-into-machine-learning | GITROOM - November 2, 2015

    […] Useful Pandas Snippets […]

  2. Dive into Machine Learning with Python Jupyter Notebook and Scikit-Learn-IT大道 - February 5, 2016

    […] Useful Pandas Snippets […]

  3. Dive into Machine Learning – Will - March 13, 2016

    […] Useful Pandas Snippets […]

  4. Подборка ссылок для изучения Python — IT-News.club - November 11, 2016

    […] Useful Pandas Snippets […]

  5. Подборка ресурсов для изучения Python — IT-News.club - January 2, 2017

    […] Useful Pandas Snippets […]

Leave a Reply