# Map function to only some columns

**URL:** <https://discourse.julialang.org/t/map-function-to-only-some-columns/35344>\
**Category:** General Usage\
**Tags:** question, dataframes\
**Created:** [March 1, 2020, 12:44am UTC](https://discourse.julialang.org/t/map-function-to-only-some-columns/35344 "2020-03-01T00:44:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tbeason](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tbeason/32/15898_2.png) [@tbeason](https://discourse.julialang.org/u/tbeason)\
**Post date:** [March 1, 2020, 12:44am UTC](https://discourse.julialang.org/t/map-function-to-only-some-columns/35344/1 "2020-03-01T00:44:55Z")

</div>

Many times I want to map a function over a DataFrame but not all of its columns. For example, suppose the first column is a `Date` column, but the remainder are `Float64` columns, and I basically just want the first column to remain untouched.

Here is what I am doing right now

```julia
df_rates = hcat(df_levels[:,:YEAR],mapcols(loggrowth,df_levels[:,Not(:YEAR)]))

```

but this seems fragile.

Is this “map to all except X” something that has been discussed?

---

<div class="post-metadata">

**Author:** ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)\
**Post date:** [March 1, 2020, 1:23am UTC](https://discourse.julialang.org/t/map-function-to-only-some-columns/35344/2 "2020-03-01T01:23:06Z")

</div>

[https://www.queryverse.org/Query.jl/stable/standalonequerycommands/#The-@map-command-1](https://www.queryverse.org/Query.jl/stable/standalonequerycommands/#The-@map-command-1)
