Python Polars Cheatsheet (based on our O'Reilly book)

(opensource.posit.co)

57 points | by jeroenjanssens 2 hours ago

2 comments

  • jeroenjanssens 2 hours ago
    We spent the last few weeks compressing our book, Python Polars: The Definitive Guide (nearly 500 pages), down to a two-page cheatsheet. It's a highly lossy compression, but hopefully a useful one! Besides the PDF, there's also an accessible HTML version.

    We're curious to hear what you think. Let us know if we missed any of your favorite Polars operations, or if you have any feedback on how we organized it.

    • grim_io 1 hour ago
      Is there an .MD version? For, uh, reasons :)
      • qrobit 1 hour ago
        I believe the complete HTML version is right below the "Download PDF" button. Also I bet you could reproduce the cheatsheet using this HTML converted to markdown and some example from how other Posit (formerly RStudio) cheatsheets are made: https://github.com/rstudio/cheatsheets/tree/main/html
  • clircle 1 hour ago
    I get that the data science world has moved on to python, but I always felt that R's data.table had the slickest dataframe developer experience. I have toyed with Polars for a few hours, maybe I should give it a better chance.
    • epihelix 7 minutes ago
      Data science is a broad church, but my own branch of it (molecular biology, genomics and epigenetics, bioinformatics) and my partner's (ecology) are still very much R-based and entrenched. If you primarily care about statistical modeling, then R still wins (easily).
    • mihaelm 1 hour ago
      The bare R experience is not that great, to put it mildly, but it's a whole other story if you add tidyverse on top of it. The data work becomes really easy then, but I still prefer Python because of familiarity and a better experience & ecosystem when you want to do anything beyond data wrangling & analysis.

      I found `polars` to be a better experience than `pandas` even though I'd say it leaks some "Rustisms" in its Python APIs. But LLMs alleviate those pains and it's easy enough to review. I'd say it's even easier when there's less of a chance of implicit behavior.

    • qsort 1 hour ago
      If your work is more focused on statistics or pure modeling, then I agree R wins hands down. The issue is that most projects have "unclean" parts where you have to gather data from multiple sources, use connectors for services, S3 buckets and whatnot; dealing with that mess is where Python really shines.

      AI probably changes the equation to some extent, but I still believe I'd rather maintain a complicated data pipeline like that in Python rather than R.

      • jordansgoodman 54 minutes ago
        Agreed. If the R community developed more data pipeline frameworks, following the "tidyverse" way of doing things, R would be my go to choice for all data related work.
    • therrop 1 hour ago
      [dead]