# Mapreduce dataframe columns elementwise AND

**URL:** <https://discourse.julialang.org/t/mapreduce-dataframe-columns-elementwise-and/43982>\
**Category:** General Usage\
**Created:** [July 30, 2020, 2:43pm UTC](https://discourse.julialang.org/t/mapreduce-dataframe-columns-elementwise-and/43982 "2020-07-30T14:43:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![bernhard](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bernhard/32/2619_2.png) [@bernhard](https://discourse.julialang.org/u/bernhard)\
**Post date:** [July 30, 2020, 2:43pm UTC](https://discourse.julialang.org/t/mapreduce-dataframe-columns-elementwise-and/43982/1 "2020-07-30T14:43:35Z")

</div>

Is there a specific reason why I need to define `myop` in the snippet below?  
Otherwise things do not work for me.

```julia
using DataFrames 

dff=DataFrame(a=trues(4),b=trues(4),c=2*ones(4))
cnms = [:a, :b]

#fails
mapreduce(x->dff[!,x], .& , cnms)  

#works
myop(x,y) = x .& y
mapreduce(x->dff[!,x], myop , cnms)  

```

---

<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:** [July 30, 2020, 4:10pm UTC](https://discourse.julialang.org/t/mapreduce-dataframe-columns-elementwise-and/43982/3 "2020-07-30T16:10:36Z")

</div>

I think this is a parsing thing. `.&` isn’t a function.

I’ve wanted this before as well, an easy way to refer to the broadcasted version of a function via, for example, `Broadcast(fun)`.

also, note that you can use `eachcol` here instead of iterating through the names.

---

<div class="post-metadata">

**Author:** ![bernhard](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bernhard/32/2619_2.png) [@bernhard](https://discourse.julialang.org/u/bernhard)\
**Post date:** [July 30, 2020, 6:17pm UTC](https://discourse.julialang.org/t/mapreduce-dataframe-columns-elementwise-and/43982/4 "2020-07-30T18:17:10Z")

</div>

Hm. Ok.  
regarding `eachcol`: in my actual use case I only iterate over a subset of all columns.
