code: def get_stock_weight_df(positions):
      """get_stock_weight_df
      :param positions: Given a positions from backtest result.
      :return:          A weight distribution for the position
      """
      stock_weight = []
      index = []
      for date in sorted(positions.keys()):
          pos = positions[date]
          if isinstance(pos, dict):
              pos = Position(position_dict=pos)
          index.append(date)
          stock_weight.append(
              pos.get_stock_weight_dict(only_stock=True)
          )
      return pd.DataFrame(stock_weight, index=index)
  
file_path: qlib/qlib/backtest/profit_attribution.py
imports: import datetime
  from pathlib import Path
  import numpy
  import pandas
  from ..config import C
  from ..data import D
  from .position import Position
label_desc: Use image node_id 2 for calling a global function with example usage: get_stock_weight_df(positions) and returns: pd