title: Compare two unequal size numpy arrays and fill the exclusion elements with nan
body: <p>I need to do an element-by-element match of a 6x3 array with a 2x2 array. Return the bigger array with a True or False in the corresponding elements based on a match or no match. For the elements in the bigger array that cannot be compared e.g. column 3 and rows 3 to 6, I need to fill with NaN.</p>
  <p>Here's my pseudo code:</p>
  <pre><code>first_arr_rows, first_arr_cols = 6, 3  # This is an example and will be dynamically initialized
  sec_arr_rows, sec_arr_cols = 2, 2      # This is an example and will be dynamically initialized
  if (sec_arr_cols &lt;= first_arr_cols) and (sec_arr_rows &lt;= first_arr_rows):
      compared = arr1[:sec_arr_rows,:sec_arr_cols] == arr2[:sec_arr_rows,:sec_arr_cols]
  # the above statement creates a 2x2 array
      new_cols = np.zeros((first_arr_rows, first_arr_cols - sec_arr_cols))
      new_rows = np.zeros((first_arr_rows - sec_arr_rows, compared.shape[1]))
      compared = np.append(compared, new_rows, axis=0)
      compared = np.append(compared, new_cols, axis=1)
      compared[sec_arr_rows+1:,:] = np.nan 
      compared[:,sec_arr_cols:] = np.nan 
  </code></pre>
  <p>Is there a simpler, more efficient way in Python to achieve this?</p>