code: def test_grandparent(self, es):
      # test sorting by time works correctly across several generations
      log = es["log"]
  
      # For one user, change a log event to be newer than the user's normal
      # last time index. This event should be from a different session than
      # the current last time index.
      df = to_pandas(log)
      df["datetime"][5] = pd.Timestamp("2011-4-09 10:40:01")
      df = (
          df.set_index("datetime", append=True)
          .sort_index(level=[1, 0], kind="mergesort")
          .reset_index("datetime", drop=False)
      )
      if es.dataframe_type == Library.DASK:
          df = dd.from_pandas(df, npartitions=2)
      if es.dataframe_type == Library.SPARK:
          df = ps.from_pandas(df)
      es.replace_dataframe(dataframe_name="log", df=df)
      es.add_last_time_indexes()
      customers = es["customers"]
  
      true_customers_lti = pd.Series(
          [
              datetime(2011, 4, 9, 10, 40, 1),
              datetime(2011, 4, 10, 10, 41, 6),
              datetime(2011, 4, 10, 11, 10, 3),
          ],
      )
  
      lti_name = customers.ww.metadata.get("last_time_index")
      assert len(customers[lti_name]) == 3
      sorted_lti = to_pandas(customers).sort_values("id")[lti_name]
      for v1, v2 in zip(sorted_lti, true_customers_lti):
          assert (pd.isnull(v1) and pd.isnull(v2)) or v1 == v2
  
imports: from datetime import datetime
  import pandas
  import pytest
  from woodwork.logical_types import Categorical, Datetime, Integer
  from featuretools.entityset.entityset import LTI_COLUMN_NAME
  from featuretools.tests.testing_utils import to_pandas
  from featuretools.utils.gen_utils import Library, import_or_none
label_desc: Use image node_id 12 for calling the TestLastTimeIndex obj's underlying member method code with example usage: obj.test_grandparent(es) without return types