File tree Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -369,12 +369,12 @@ The ability to make changes in dataframes is important to generate a clean datas
369369** 1.** We can use conditional logic to "keep" certain values and replace others
370370
371371``` {code-cell} ipython3
372- df.with_columns( # add data column to the same dataframe
373- pl.when(pl.col('POP') >= 20000) # when population is greater than 20,000
372+ df.with_columns(
373+ pl.when(pl.col('POP') >= 20000) # when population >= 20000
374374 .then(pl.col('POP')) # keep the population value
375- .otherwise(None) # otherwise set the value to null
376- .alias('POP_filtered') # save results in column POP_filtered
377- ).select(['country', 'POP', 'POP_filtered']) # select the columns of interest
375+ .otherwise(None) # otherwise set to null
376+ .alias('POP_filtered') # save results in POP_filtered
377+ ).select(['country', 'POP', 'POP_filtered']) # select the columns
378378```
379379
380380** 2.** We can modify specific values based on conditions
You can’t perform that action at this time.
0 commit comments