code: def mock_transactions_from_positions(positions):
      # Compute the day-to-day diff of the positions frame, then collapse
      # that into a frame with one row per day per asset.
      transactions = (
          pd.melt(
              positions.diff().dropna().reset_index(),
              id_vars=["index"],
              var_name="symbol",
              value_name="amount",
          )
          .sort_values(["index", "symbol"])
          .set_index("index")
      )
  
      # Filter out positions that didn't actually change.
      transactions = transactions[transactions.amount != 0]
  
      # Tack on a price column.
      transactions["price"] = 100.0
  
      return transactions
  
file_path: pyfolio/pyfolio/tests/test_perf_attrib.py
imports: import numpy
  import pandas
  import unittest
  import warnings
  import empyrical
  from pyfolio.perf_attrib import perf_attrib, create_perf_attrib_stats, _cumulative_returns_less_costs
label_desc: Use image node_id 3 for calling a global function with example usage: mock_transactions_from_positions(positions) and returns: transactions