# Whats the easiest way to set a ceiling to column values in a DataFrame

**URL:** <https://discourse.julialang.org/t/whats-the-easiest-way-to-set-a-ceiling-to-column-values-in-a-dataframe/42174>\
**Category:** General Usage\
**Created:** [June 27, 2020, 9:55pm UTC](https://discourse.julialang.org/t/whats-the-easiest-way-to-set-a-ceiling-to-column-values-in-a-dataframe/42174 "2020-06-27T21:55:04Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Julia1](https://avatars.discourse-cdn.com/v4/letter/j/db5fbb/32.png) [@Julia1](https://discourse.julialang.org/u/Julia1)\
**Post date:** [June 27, 2020, 9:55pm UTC](https://discourse.julialang.org/t/whats-the-easiest-way-to-set-a-ceiling-to-column-values-in-a-dataframe/42174/1 "2020-06-27T21:55:04Z")

</div>

Hi how’s it going?

I want to set a ceiling value to a column in my dataframe so that every value greater than 1.0 is equal to 1.0, everything else remains untouched.

What’s the easiest way to do this?

---

<div class="post-metadata">

**Author:** ![pdeffebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pdeffebach/32/10320_2.png) [@pdeffebach](https://discourse.julialang.org/u/pdeffebach)\
**Post date:** [June 27, 2020, 10:46pm UTC](https://discourse.julialang.org/t/whats-the-easiest-way-to-set-a-ceiling-to-column-values-in-a-dataframe/42174/2 "2020-06-27T22:46:11Z")

</div>

The function `clamp` will do this.

```julia
julia> x = randn(1000);

julia> clamp.(x, -Inf, 1)

```

There is also a modifying `clamp!` that modifies the vector.

---

<div class="post-metadata">

**Author:** ![Julia1](https://avatars.discourse-cdn.com/v4/letter/j/db5fbb/32.png) [@Julia1](https://discourse.julialang.org/u/Julia1)\
**Post date:** [June 28, 2020, 3:16pm UTC](https://discourse.julialang.org/t/whats-the-easiest-way-to-set-a-ceiling-to-column-values-in-a-dataframe/42174/3 "2020-06-28T15:16:21Z")

</div>

thank you!
