code: def fix_Yahoo_returning_prepost_unrequested(
      quotes, interval, tradingPeriods
  ):
      # Sometimes Yahoo returns post-market data despite not requesting it.
      # Normally happens on half-day early closes.
      #
      # And sometimes returns pre-market data despite not requesting it.
      # E.g. some London tickers.
      tps_df = tradingPeriods.copy()
      tps_df["_date"] = tps_df.index.date
      quotes["_date"] = quotes.index.date
      idx = quotes.index.copy()
      quotes = quotes.merge(tps_df, how="left")
      quotes.index = idx
      # "end" = end of regular trading hours (including any auction)
      f_drop = quotes.index >= quotes["end"]
      f_drop = f_drop | (quotes.index < quotes["start"])
      if f_drop.any():
          # When printing report, ignore rows that were already NaNs:
          # f_na = quotes[["Open","Close"]].isna().all(axis=1)
          # n_nna = quotes.shape[0] - _np.sum(f_na)
          # n_drop_nna = _np.sum(f_drop & ~f_na)
          # quotes_dropped = quotes[f_drop]
          # if debug and n_drop_nna > 0:
          #     print(f"Dropping {n_drop_nna}/{n_nna} intervals for falling outside regular trading hours")
          quotes = quotes[~f_drop]
      quotes = quotes.drop(["_date", "start", "end"], axis=1)
      return quotes
  
imports: from __future__ import print_function
  import datetime
  import logging
  import re
  import sys
  import threading
  from functools import lru_cache
  from inspect import getmembers
  from types import FunctionType
  from typing import List, Optional
  import numpy
  import pandas
  import pytz
  import requests
  from dateutil.relativedelta import relativedelta
  from pytz import UnknownTimeZoneError
  from yfinance import const
  from .const import _BASE_URL_
label_desc: Use image node_id 28 for calling a global function with example usage: fix_Yahoo_returning_prepost_unrequested(quotes, interval, tradingPeriods) and returns: quotes