code: def calc_paused_num(
      df: pd.DataFrame, _date_field_name, _symbol_field_name
  ):
      """calc paused num
      This method adds the paused_num field
          - The `paused_num` is the number of consecutive days of trading suspension.
      """
      _symbol = df.iloc[0][_symbol_field_name]
      df = df.copy()
      df["_tmp_date"] = df[_date_field_name].apply(
          lambda x: pd.Timestamp(x).date()
      )
      # remove data that starts and ends with `np.nan` all day
      all_data = []
      # Record the number of consecutive trading days where the whole day is nan, to remove the last trading day where the whole day is nan
      all_nan_nums = 0
      # Record the number of consecutive occurrences of trading days that are not nan throughout the day
      not_nan_nums = 0
      for _date, _df in df.groupby("_tmp_date"):
          _df["paused"] = 0
          if not _df.loc[_df["volume"] < 0].empty:
              logger.warning(
                  f"volume < 0, will fill np.nan: {_date} {_symbol}"
              )
              _df.loc[_df["volume"] < 0, "volume"] = np.nan
  
          check_fields = set(_df.columns) - {
              "_tmp_date",
              "paused",
              "factor",
              _date_field_name,
              _symbol_field_name,
          }
          if (
              _df.loc[:, list(check_fields)].isna().values.all()
              or (_df["volume"] == 0).all()
          ):
              all_nan_nums += 1
              not_nan_nums = 0
              _df["paused"] = 1
              if all_data:
                  _df["paused_num"] = not_nan_nums
                  all_data.append(_df)
          else:
              all_nan_nums = 0
              not_nan_nums += 1
              _df["paused_num"] = not_nan_nums
              all_data.append(_df)
      all_data = all_data[: len(all_data) - all_nan_nums]
      if all_data:
          df = pd.concat(all_data, sort=False)
      else:
          logger.warning(f"data is empty: {_symbol}")
          df = pd.DataFrame()
          return df
      del df["_tmp_date"]
      return df
  
imports: import re
  import copy
  import importlib
  import time
  import bisect
  import pickle
  import random
  import requests
  import functools
  from pathlib import Path
  from typing import Iterable, Tuple, List
  import numpy
  import pandas
  from lxml import etree
  from loguru import logger
  from yahooquery import Ticker
  from tqdm import tqdm
  from functools import partial
  from concurrent.futures import ProcessPoolExecutor
  from bs4 import BeautifulSoup
label_desc: Use image node_id 18 for calling a global function with example usage: calc_paused_num(df, _date_field_name, _symbol_field_name) and returns: df, df