title: Checking elements in multiple columns of Dataframe in Julia
body: <p>I have a question regarding the use of conditions in any loop while manipulating on DataFrame.</p>
  <p>For example,
  I have a DataFrame</p>
  <pre><code>df:
  
  a b c
  
  1 2 5
  3 4 3
  2 1 7
  6 3 6
  5 1 9
  </code></pre>
  <p>I am trying to write a loop with a condition which checks on two cols (<code>a and b</code>) at a time and if the value <code>i</code> is available in either or both column then it should take the values from column <code>c</code> and store it in an array.</p>
  <p>Using which I can later perform the statistical operations like finding mean of the array.</p>
  <p>I have written a simplified code snippet for this task:</p>
  <pre><code>for i in 1:5
    result1 = Float64[]
    result2 = Float64[]
    if (df[:, :a] = i) 
        push!(result1, df[:, :c])
    elseif (df[:, :b] = i)
        push!(result2, df[:, :c])
    end
  
    unique!(result1)
    unique!(result2)
  
    result = vcat(result1, result2)
  
    global mean_val = mean(result)
  end
  </code></pre>
  <p>Here, the <code>i</code> value will range from 1 to 5 and for each value both the columns <code>a and b</code> will be checked for its existence, if the value exist then value in column <code>c</code> should be pushed to the respected result array.</p>
  <p>I have tried using some other suggestions from community like:</p>
  <p>Code Example 1:</p>
  <pre><code>
  for i in 1:5
    mean_val = mean(df[:, :c] for i in (&quot;a&quot;, &quot;b&quot;)
  end
  </code></pre>
  <p>Code Example 2:</p>
  <pre><code>for i in 1:5
    df.row = axes(df, 1)
    mean_val = mean((filter(x-&gt;x[:a] == i || x[:b] == i ,df))[:c])
  end
  </code></pre>
  <p>However these do not work and return a desired output.</p>
  <p>Please advice on my mistake in the code.
  Also, please do suggest if there is any document which explains about implementing multiple conditions in a statement, and accessing dataframe elements for any other operations in julia.</p>
  <p>Thank you in advance</p>