code: def detect_freq_period(deltas: pd.DataFrame, tss, n_points) -> tuple:
      """
      Helper method that, based on the most popular interval for a time series, determines its seasonal peridiocity (sp).
      This bit of information can be crucial for good modelling with methods like ARIMA.
  
      Supported time intervals are:
          * 'year'
          * 'semestral'
          * 'quarter'
          * 'bimonthly'
          * 'monthly'
          * 'weekly'
          * 'daily'
          * 'hourly'
          * 'minute'
          * 'second'
  
      Note: all computations assume that the first provided `order_by` column is the one that specifies the sp.
  
      :param deltas: output of `get_delta`, has the most popular interval for each time series.
      :param tss: timeseries settings.
  
      :return: for all time series 1) a dictionary with its sp and 2) a dictionary with the detected sampling frequency
      """  # noqa
      secs_to_interval = {
          "yearly": 60 * 60 * 24 * 365,
          "quarterly": 60 * 60 * 24 * 365 // 4,
          "bimonthly": 60 * 60 * 24 * 31 * 2,
          "monthly": 60 * 60 * 24 * 31,
          "weekly": 60 * 60 * 24 * 7,
          "daily": 60 * 60 * 24,
          "hourly": 60 * 60,
          "minute": 60,
          "second": 1,
          "millisecond": 0.001,
          "microsecond": 1e-6,
          "nanosecond": 1e-9,
          "constant": 0,
      }
      freq_to_period = {
          interval: period
          for (interval, period) in tss.interval_periods
      }
      for tag, period in (
          ("yearly", 1),
          ("quarterly", 4),
          ("bimonthly", 6),
          ("monthly", 12),
          ("weekly", 52),
          ("daily", 7),
          ("hourly", 24),
          ("minute", 1),
          ("second", 1),
          ("constant", 0),
      ):
          if tag not in freq_to_period.keys():
              if period <= n_points:
                  freq_to_period[tag] = period
              else:
                  freq_to_period[tag] = None
  
      diffs = [
          (tag, abs(deltas - secs))
          for tag, secs in secs_to_interval.items()
      ]
      freq, min_diff = sorted(diffs, key=lambda x: x[1])[0]
      multiplier = 1
      if secs_to_interval[freq]:
          multiplier += int(min_diff / secs_to_interval[freq])
      return freq_to_pandas(
          freq, multiplier=multiplier
      ), freq_to_period.get(freq, 1)
  
file_path: lightwood/lightwood/helpers/ts.py
imports: from typing import Tuple, Dict
  from datetime import datetime
  import numpy
  import pandas
label_desc: Use image node_id 6 for calling a global function with example usage: detect_freq_period(deltas, tss, n_points) and returns: freq_to_pandas,  freq_to_period