title: Compare values in 2 dataframes with IF conditions output (1, 0, -1)
body: <p>EDIT Solution at the bottom</p>
  <p>So I'm trying to compare two dataframes. When there is a positive crossover it should output 1, if no crossover 0, if negative crossover -1. The IF values should be outputted in a new dataframe.</p>
  <p>I see online about iloc and lambda but not sure how to do it across 2 different dataframes?</p>
  <p>Below shows correctly the crossover logic for positive and gives True. I would like to add the logic with 1, 0 and -1</p>
  <pre><code>macd_crossover = (macd &gt; macd_signal) &amp; (macd.shift(1) &lt; macd_signal.shift(1))
  </code></pre>
  <p>macd example</p>
  <pre><code>              btc 
  2021-08-26.   150 
  2021-08-27.   200  
  2021-08-28.   220
  2021-08-29.   120
  </code></pre>
  <p>macd_signal example</p>
  <pre><code>              btc 
  2021-08-26.   160 
  2021-08-27.   160  
  2021-08-28.   200
  2021-08-29.   190
  </code></pre>
  <p>expected output</p>
  <pre><code>              btc 
  2021-08-26.   0 
  2021-08-27.   1 (crossover happens)
  2021-08-28.   0
  2021-08-29.   -1 (crossover happens)
  </code></pre>
  <p>SOLUTION (for me)</p>
  <pre><code>df_macd_diff = df_macd - df_macd_signal 
  df_macd_crossover = pd.DataFrame(np.select(condlist= [(df_macd_diff &gt; 0) &amp; (df_macd_diff.shift(1) &lt; 0), (df_macd_diff &lt; 0) &amp; (df_macd_diff.shift(1) &gt; 0)], choicelist = [1, -1], default = 0), index = df.index, columns = df.columns)
  </code></pre>