Skip to content

Instantly share code, notes, and snippets.

@heronshoes
Created September 1, 2022 21:06
Show Gist options
  • Save heronshoes/6de174606b810746abcb2cc21b6c2adc to your computer and use it in GitHub Desktop.
Save heronshoes/6de174606b810746abcb2cc21b6c2adc to your computer and use it in GitHub Desktop.
Comparing between RedAmber, dplyr/tidyr and pandas

Comparing between RedAmber, dplyr/tidyr and pandas (tentative)

This is the comparison of basic feature between RedAmber and other major DataFrame libraries, comparing only for the method 'verbs' ignoring parameters and options.

Remarks:

  1. dataframe represents 2D data containers such as DataFrame, tibble or Table.
  2. vector represents 1D data containers such as Vector, Series or Column.

Select columns (variables)

Features RedAmber tidyverse pandas
Select columns as a dataframe pick, drop, [] dplyr::select, dplyr::select_if [], loc[], iloc[], drop, select_dtypes
Select a column as a vector [], v dplyr::pull [], loc[], iloc[]
Move columns to a new position pick, [] relocate [], reindex, loc[], iloc[]

|

Select rows (observations)

Features RedAmber tidyverse pandas
Select rows
that meet logical criteria as a dataframe
slice, remove, [] dplyr::filter [], filter, query, loc[]
Select rows
by position as a dataframe
slice, remove, [] dplyr::slice iloc[], drop
Move rows to a new position slice, [] dplyr::filter, dplyr::slice reindex, loc[], iloc[]

|

Update columns / create new columns

Features RedAmber tidyverse pandas
Update existing columns assign dplyr::mutate assign, []=
Create new columns assign, assign_left dplyr::mutate apply
Compute new columns, drop others new transmute (dfply:)transmute
Rename columns rename dplyr::rename, dplyr::rename_with, purrr::set_names rename, set_axis
Sort dataframe slice(sort_index),
[].(sort_index)
dplyr::arrange sort_values

|

Reshape dataframe

Features RedAmber tidyverse pandas
Gather columns into rows
(create a longer dataframe)
to_long tidyr::pivot_longer melt
Spread rows into columns
(create a wider dataframe)
to_wide tidyr::pivot_wider pivot
transpose a wide dataframe transpose transpose, t transpose, T

|

Grouping

Features RedAmber tidyverse pandas
Grouping group, group.summarize dplyr::group_by %>% dplyr::summarise groupby.agg

|

Combine dataframes or tables (scheduled on v0.2.1 or later)

Features RedAmber tidyverse pandas
Combine additional columns concat, concat_col dplyr::bind_cols concat
Combine additional rows concat, concat_row dplyr::bind_rows concat
Left join join, left_join dplyr::left_join merge
Inner join join, inner_join dplyr::inner_join merge
Full join join, full_join, outer_join dplyr::full_join merge
Collect rows that appear in x or y union, concat dplyr::union concat
Collect rows that appear in both x and y intersect, concat dplyr::intersect isin.apply
Collect rows that appear in x but not y diff, concat dplyr::setdiff is_in.apply

|

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment