I guess most of us have already used something like this (at least if you are using the tidyverse):
library(tidyverse)
example <- mtcars
example <- example %>%
select(- mpg)
My question: I know there is a shortcut for this part:
example <- example %>% ...
But I can neither remember nor find it on Google.
I think it was something similar to this %<>%.
Can anyone help?
Please excuse me if this question was already asked before.
Best regards
Suppose that you want to replace multiple values with multiple new values for an individual DataFrame column. In that case, you may use this template: df['column name'] = df['column name']. replace(['1st old value','2nd old value',...],['1st new value','2nd new value',...])
replace() function is used to replace values in column (one value with another value on all columns). This method takes to_replace, value, inplace, limit, regex and method as parameters and returns a new DataFrame. When inplace=True is used, it replaces on existing DataFrame object and returns None value.
In order to replace a value in Pandas DataFrame, use the replace() method with the column the from and to values.
This lhs %<>% rhs
from the magrittr
package. So in your case example %<>%
select(- mpg)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With