code: def total_time(df: DataFrame, tf: str = "years") -> float:
      """Calculates the total time of a DataFrame. Difference of the Last and
      First index. Options: 'months', 'weeks', 'days', 'hours', 'minutes'
      and 'seconds'. Default: 'years'.
      Useful for annualization."""
      time_diff = df.index[-1] - df.index[0]
      TimeFrame = {
          "years": time_diff.days / RATE["TRADING_DAYS_PER_YEAR"],
          "months": time_diff.days / 30.417,
          "weeks": time_diff.days / 7,
          "days": time_diff.days,
          "hours": time_diff.days * 24,
          "minutes": time_diff.total_seconds() / 60,
          "seconds": time_diff.total_seconds(),
      }
  
      if isinstance(tf, str) and tf in TimeFrame.keys():
          return TimeFrame[tf]
      return TimeFrame["years"]
  
file_path: pandas-ta/pandas_ta/utils/_time.py
imports: from datetime import datetime
  from time import localtime, perf_counter
  from typing import Tuple
  from pandas import DataFrame, Timestamp
  from pandas_ta import EXCHANGE_TZ, RATE
label_desc: Use image node_id 7 for calling a global function with example usage: total_time(df, tf) and returns: TimeFrame, TimeFrame