title: Iteration over columns and rows in Pandas Dataframe
body: <p>Say I have a dataframe that looks like:</p>
  
  <pre><code>d = {'option1': ['1', '0', '1', '1'], 'option2': ['0', '0', '1', '0'], 'option3': ['1', '1', '0', '0'], 'views': ['6', '10', '5', '2']
  df = pd.DataFrame(data=d)
  
  print(df)
  
    option1 option2 option3 views
  0       1       0       1     6
  1       0       0       1    10
  2       1       1       0     5
  3       1       0       0     2
  </code></pre>
  
  <p>I'm trying to build a for loop that iterates over each column (except the column "views") and each row. If the value of a cell is not 0, I want to replace it with the corresponding value of the column "views" from the same row.</p>
  
  <p>The following output is required (should be easier to understand):</p>
  
  <pre><code>  option1 option2 option3 views
  0       6       0       6     6
  1       0       0      10    10
  2       5       5       0     5
  3       2       0       0     2
  </code></pre>
  
  <p>I tried something like:</p>
  
  <pre><code>df_range = len(df)
  
  for column in df:
      for i in range(df_range):
          if column != 0:
              column = df.views[i]
  </code></pre>
  
  <p>But I know I'm missing something, it does not work.</p>
  
  <p>Also please note that in my real dataframe, I have dozens of columns, so I need something that iterates over each column automatically. Thanks!!</p>
  
  <p>I saw this thread <a href="https://stackoverflow.com/questions/23330654/update-a-dataframe-in-pandas-while-iterating-row-by-row">Update a dataframe in pandas while iterating row by row</a> but it doesn't exactly apply to my problem, because I'm not only going row by row, I also need to go column by column.</p>