nodes: 0, module; 1, function_definition; 2, function_name:assemble_data; 3, parameters; 4, block; 5, identifier:data_dfs; 6, identifier:concat_direction; 7, expression_statement; 8, if_statement; 9, comment:# Sort both indices; 10, expression_statement; 11, return_statement; 12, comment:""" Assemble the data dfs together. Both indices are sorted.
  
      Args:
          data_dfs (list of pandas dfs)
          concat_direction (string): 'horiz' or 'vert'
  
      Returns:
          all_data_df_sorted (pandas df)
  
      """; 13, comparison_operator:concat_direction == "horiz"; 14, comment:# Concatenate the data_dfs horizontally; 15, block; 16, elif_clause; 17, assignment; 18, identifier:all_data_df_sorted; 19, identifier:concat_direction; 20, string:"horiz"; 21, expression_statement; 22, comment:# Sanity check: the number of columns in all_data_df should; 23, comment:# correspond to the sum of the number of columns in the input dfs; 24, expression_statement; 25, expression_statement; 26, expression_statement; 27, assert_statement; 28, comparison_operator:concat_direction == "vert"; 29, comment:# Concatenate the data_dfs vertically; 30, block; 31, identifier:all_data_df_sorted; 32, call; 33, assignment; 34, assignment; 35, call; 36, assignment; 37, comparison_operator:n_cols == n_cols_cumulative; 38, identifier:concat_direction; 39, string:"vert"; 40, expression_statement; 41, comment:# Sanity check: the number of rows in all_data_df should; 42, comment:# correspond to the sum of the number of rows in the input dfs; 43, expression_statement; 44, expression_statement; 45, expression_statement; 46, assert_statement; 47, attribute; 48, argument_list; 49, identifier:all_data_df; 50, call; 51, identifier:n_cols; 52, subscript; 53, attribute; 54, argument_list; 55, identifier:n_cols_cumulative; 56, call; 57, identifier:n_cols; 58, identifier:n_cols_cumulative; 59, assignment; 60, assignment; 61, call; 62, assignment; 63, comparison_operator:n_rows == n_rows_cumulative; 64, call; 65, identifier:sort_index; 66, keyword_argument; 67, attribute; 68, argument_list; 69, attribute; 70, integer:1; 71, identifier:logger; 72, identifier:debug; 73, call; 74, identifier:sum; 75, argument_list; 76, identifier:all_data_df; 77, call; 78, identifier:n_rows; 79, subscript; 80, attribute; 81, argument_list; 82, identifier:n_rows_cumulative; 83, call; 84, identifier:n_rows; 85, identifier:n_rows_cumulative; 86, attribute; 87, argument_list; 88, identifier:axis; 89, integer:1; 90, identifier:pd; 91, identifier:concat; 92, identifier:data_dfs; 93, keyword_argument; 94, identifier:all_data_df; 95, identifier:shape; 96, attribute; 97, argument_list; 98, list_comprehension; 99, attribute; 100, argument_list; 101, attribute; 102, integer:0; 103, identifier:logger; 104, identifier:debug; 105, call; 106, identifier:sum; 107, argument_list; 108, identifier:all_data_df; 109, identifier:sort_index; 110, keyword_argument; 111, identifier:axis; 112, integer:1; 113, string:"all_data_df.shape[1]: {}"; 114, identifier:format; 115, identifier:n_cols; 116, subscript; 117, for_in_clause; 118, identifier:pd; 119, identifier:concat; 120, identifier:data_dfs; 121, keyword_argument; 122, identifier:all_data_df; 123, identifier:shape; 124, attribute; 125, argument_list; 126, list_comprehension; 127, identifier:axis; 128, integer:0; 129, attribute; 130, integer:1; 131, identifier:df; 132, identifier:data_dfs; 133, identifier:axis; 134, integer:0; 135, string:"all_data_df.shape[0]: {}"; 136, identifier:format; 137, identifier:n_rows; 138, subscript; 139, for_in_clause; 140, identifier:df; 141, identifier:shape; 142, attribute; 143, integer:0; 144, identifier:df; 145, identifier:data_dfs; 146, identifier:df; 147, identifier:shape
code: def assemble_data(data_dfs, concat_direction):
      """ Assemble the data dfs together. Both indices are sorted.
  
      Args:
          data_dfs (list of pandas dfs)
          concat_direction (string): 'horiz' or 'vert'
  
      Returns:
          all_data_df_sorted (pandas df)
  
      """
      if concat_direction == "horiz":
          # Concatenate the data_dfs horizontally
          all_data_df = pd.concat(data_dfs, axis=1)
  
          # Sanity check: the number of columns in all_data_df should
          # correspond to the sum of the number of columns in the input dfs
          n_cols = all_data_df.shape[1]
          logger.debug("all_data_df.shape[1]: {}".format(n_cols))
          n_cols_cumulative = sum([df.shape[1] for df in data_dfs])
          assert n_cols == n_cols_cumulative
  
      elif concat_direction == "vert":
  
          # Concatenate the data_dfs vertically
          all_data_df = pd.concat(data_dfs, axis=0)
  
          # Sanity check: the number of rows in all_data_df should
          # correspond to the sum of the number of rows in the input dfs
          n_rows = all_data_df.shape[0]
          logger.debug("all_data_df.shape[0]: {}".format(n_rows))
          n_rows_cumulative = sum([df.shape[0] for df in data_dfs])
          assert n_rows == n_rows_cumulative
  
      # Sort both indices
      all_data_df_sorted = all_data_df.sort_index(axis=0).sort_index(axis=1)
  
      return all_data_df_sorted