code: def map_transaction(txn):
      """
      Maps a single transaction row to a dictionary.
  
      Parameters
      ----------
      txn : pd.DataFrame
          A single transaction object to convert to a dictionary.
  
      Returns
      -------
      dict
          Mapped transaction.
      """
  
      if isinstance(txn["sid"], dict):
          sid = txn["sid"]["sid"]
          symbol = txn["sid"]["symbol"]
      else:
          sid = txn["sid"]
          symbol = txn["sid"]
  
      return {
          "sid": sid,
          "symbol": symbol,
          "price": txn["price"],
          "order_id": txn["order_id"],
          "amount": txn["amount"],
          "commission": txn["commission"],
          "dt": txn["dt"],
      }
  
imports: from __future__ import division
  import pandas
label_desc: Use image node_id 1 for calling a global function with example usage: map_transaction(txn) and returns: dict