Answers for "round all float columns pandas"

C++
1

round all columns in R dataframe to 3 digits

round_df <- function(x, digits) {
    # round all numeric variables
    # x: data frame 
    # digits: number of digits to round
    numeric_columns <- sapply(x, mode) == 'numeric'
    x[numeric_columns] <-  round(x[numeric_columns], digits)
    x
}

round_df(data, 3)
Posted by: Guest on November-18-2020
0

pandas round floats

df_new.round(1) #number of desired decimal points
Posted by: Guest on May-20-2021

Code answers related to "round all float columns pandas"

Browse Popular Code Answers by Language