docstr: get changes with history companies
  
  Parameters
  ----------
  history_companies : pd.DataFrame
      symbol        date
      SH600000   2020-11-11
  
      dtypes:
          symbol: str
          date: pd.Timestamp
  
  Return
  --------
      pd.DataFrame:
          symbol      date        type
          SH600000  2019-11-11    add
          SH600000  2020-11-10    remove
      dtypes:
          symbol: str
          date: pd.Timestamp
          type: str, value from ["add", "remove"]
docstr_tok: ["get","changes","with","history","companies","Parameters","--","--","--","--","--","history_companies",":","pd.DataFrame","symbol","date","SH600000","2020-11-11","dtypes",":","symbol",":","str","date",":","pd.Timestamp","Return","--","--","--","--","pd.DataFrame",":","symbol","date","type","SH600000","2019-11-11","add","SH600000","2020-11-10","remove","dtypes",":","symbol",":","str","date",":","pd.Timestamp","type",":","str",",","value","from","[","``","add","''",",","``","remove","''","]"]
code: def get_changes_with_history_companies(
      self, history_companies: pd.DataFrame
  ) -> pd.DataFrame:
      """get changes with history companies
  
      Parameters
      ----------
      history_companies : pd.DataFrame
          symbol        date
          SH600000   2020-11-11
  
          dtypes:
              symbol: str
              date: pd.Timestamp
  
      Return
      --------
          pd.DataFrame:
              symbol      date        type
              SH600000  2019-11-11    add
              SH600000  2020-11-10    remove
          dtypes:
              symbol: str
              date: pd.Timestamp
              type: str, value from ["add", "remove"]
  
      """
      logger.info("parse changes from history companies......")
      last_code = []
      result_df_list = []
      _columns = [
          self.DATE_FIELD_NAME,
          self.SYMBOL_FIELD_NAME,
          self.CHANGE_TYPE_FIELD,
      ]
      for _trading_date in tqdm(
          sorted(
              history_companies[self.DATE_FIELD_NAME].unique(),
              reverse=True,
          )
      ):
          _currenet_code = history_companies[
              history_companies[self.DATE_FIELD_NAME] == _trading_date
          ][self.SYMBOL_FIELD_NAME].tolist()
          if last_code:
              add_code = list(set(last_code) - set(_currenet_code))
              remote_code = list(set(_currenet_code) - set(last_code))
              for _code in add_code:
                  result_df_list.append(
                      pd.DataFrame(
                          [
                              [
                                  get_trading_date_by_shift(
                                      self.calendar_list,
                                      _trading_date,
                                      1,
                                  ),
                                  _code,
                                  self.ADD,
                              ]
                          ],
                          columns=_columns,
                      )
                  )
              for _code in remote_code:
                  result_df_list.append(
                      pd.DataFrame(
                          [
                              [
                                  get_trading_date_by_shift(
                                      self.calendar_list,
                                      _trading_date,
                                      0,
                                  ),
                                  _code,
                                  self.REMOVE,
                              ]
                          ],
                          columns=_columns,
                      )
                  )
          last_code = _currenet_code
      df = pd.concat(result_df_list)
      logger.info("end of parse changes from history companies.")
      return df
  
file_path: qlib/scripts/data_collector/index.py
imports: import sys
  import abc
  from pathlib import Path
  from typing import List
  import pandas
  from tqdm import tqdm
  from loguru import logger
  from data_collector.utils import get_trading_date_by_shift
label_desc: Use image node_id 8 for calling the IndexBase obj's underlying member method code with example usage: obj.get_changes_with_history_companies(history_companies) and returns: df