markfairbanks / tidypolars

Tidy interface to polars
http://tidypolars.readthedocs.io
MIT License
332 stars 11 forks source link

Revisit `.rename()` syntax #38

Closed markfairbanks closed 2 years ago

markfairbanks commented 2 years ago

Should the syntax be the same as pl.DataFrame.rename? Currently polars mimics pandas syntax. Or should it be something that attempts to mimic tidyverse syntax?

Note: polars also has a .rename_col() with syntax df.rename_col('old', 'new').

markfairbanks commented 2 years ago

@mjkarlsen What if we built it to work for all 3 of these? 🤔

df = tp.Tibble(x = range(3), y = range(3))

# Option A: dplyr-like
df.rename(new_x = 'x',
          new_y = 'y')

# Option B: dplyr-like with strings
df.rename('new_x', 'x',
          'new_y', 'y') 

# Option C: pandas-like
df.rename({'x': 'new_x',
           'y': 'new_y'})

That way we wouldn't need to choose an API 😂

mjkarlsen commented 2 years ago

Love it

markfairbanks commented 2 years ago

Or should we just do options 1 & 3?