drop
Removes all rows that satisfy row condition
df.drop { weight == null || city == null }
val name by columnGroup()
val weight by column<Int?>()
val city by column<String?>()
df.drop { weight() == null || city() == null }
// or
df.drop { it[weight] == null || it[city] == null }
df.drop { it["weight"] == null || it["city"] == null }
dropNulls
Remove rows with null
values
df.dropNulls() // remove rows with null value in any column
df.dropNulls(whereAllNull = true) // remove rows with null values in all columns
df.dropNulls { city } // remove rows with null value in 'city' column
df.dropNulls { city and weight } // remove rows with null value in 'city' OR 'weight' columns
df.dropNulls(whereAllNull = true) { city and weight } // remove rows with null value in 'city' AND 'weight' columns
dropNaNs
Remove rows with NaN
values (Double.NaN
or Float.NaN
).
df.dropNaNs() // remove rows containing NaN in any column
df.dropNaNs(whereAllNaN = true) // remove rows with NaN in all columns
df.dropNaNs { weight } // remove rows where 'weight' is NaN
df.dropNaNs { age and weight } // remove rows where either 'age' or 'weight' is NaN
df.dropNaNs(whereAllNaN = true) { age and weight } // remove rows where both 'age' and 'weight' are NaN
dropNA
Remove rows with NA
values (null
, Double.NaN
, or Float.NaN
).
df.dropNA() // remove rows containing null or NaN in any column
df.dropNA(whereAllNA = true) // remove rows with null or NaN in all columns
df.dropNA { weight } // remove rows where 'weight' is null or NaN
df.dropNA { age and weight } // remove rows where either 'age' or 'weight' is null or NaN
df.dropNA(whereAllNA = true) { age and weight } // remove rows where both 'age' and 'weight' are null or NaN
Last modified: 09 December 2024