Skip to content

Instantly share code, notes, and snippets.

View kieranrcampbell's full-sized avatar

Kieran R Campbell kieranrcampbell

View GitHub Profile
@conormm
conormm / r-to-python-data-wrangling-basics.md
Last active July 23, 2024 17:45
R to Python: Data wrangling with dplyr and pandas

R to python data wrangling snippets

The dplyr package in R makes data wrangling significantly easier. The beauty of dplyr is that, by design, the options available are limited. Specifically, a set of key verbs form the core of the package. Using these verbs you can solve a wide range of data problems effectively in a shorter timeframe. Whilse transitioning to Python I have greatly missed the ease with which I can think through and solve problems using dplyr in R. The purpose of this document is to demonstrate how to execute the key dplyr verbs when manipulating data using Python (with the pandas package).

dplyr is organised around six key verbs:

# Things that need to be done just once
if (FALSE) {
  # We need the dev version of ggrepel
  devtools::install_github("slowkow/ggrepel")

  # Install Lato font on machine, then import it into extrafont library
  extrafont::font_import(pattern = "Lato")
}