code: def _stack_positions(positions, pos_in_dollars=True):
      """
      Convert positions to percentages if necessary, and change them
      to long format.
  
      Parameters
      ----------
      positions: pd.DataFrame
          Daily holdings (in dollars or percentages), indexed by date.
          Will be converted to percentages if positions are in dollars.
          Short positions show up as cash in the 'cash' column.
  
      pos_in_dollars : bool
          Flag indicating whether `positions` are in dollars or percentages
          If True, positions are in dollars.
      """
      if pos_in_dollars:
          # convert holdings to percentages
          positions = get_percent_alloc(positions)
  
      # remove cash after normalizing positions
      positions = positions.drop("cash", axis="columns")
  
      # convert positions to long format
      positions = positions.stack()
      positions.index = positions.index.set_names(["dt", "ticker"])
  
      return positions
  
file_path: pyfolio/pyfolio/perf_attrib.py
imports: from __future__ import division
  import warnings
  from collections import OrderedDict
  import empyrical
  import pandas
  import matplotlib.pyplot
  from .pos import get_percent_alloc
  from .txn import get_turnover
  from .utils import print_table, configure_legend
label_desc: Use image node_id 10 for calling a global function with example usage: _stack_positions(positions, pos_in_dollars) and returns: positions