code: def _join_by_hand(a, b, how="left"):
      join_index = a.index.join(b.index, how=how)
  
      a_re = a.reindex(join_index)
      b_re = b.reindex(join_index)
  
      result_columns = a.columns.append(b.columns)
  
      for col, s in b_re.items():
          a_re[col] = s
      return a_re.reindex(columns=result_columns)
  
imports: import re
  import numpy
  import pytest
  import pandas.util._test_decorators
  import pandas
  from pandas import Categorical, DataFrame, Index, MultiIndex, Series, Timestamp, bdate_range, concat, merge, option_context
  import pandas._testing
label_desc: Use image node_id 6 for calling a global function with example usage: _join_by_hand(a, b, how) and returns: a_re