code: def test_correct_lag_when_using_periods(df_time):
      # Expected
      date_time = [
          pd.Timestamp("2020-05-15 12:00:00"),
          pd.Timestamp("2020-05-15 12:15:00"),
          pd.Timestamp("2020-05-15 12:30:00"),
          pd.Timestamp("2020-05-15 12:45:00"),
          pd.Timestamp("2020-05-15 13:00:00"),
      ]
      expected_results = {
          "ambient_temp": [31.31, 31.51, 32.15, 32.39, 32.62],
          "module_temp": [49.18, 49.84, 52.35, 50.63, 49.61],
          "irradiation": [0.51, 0.79, 0.65, 0.76, 0.42],
          "color": ["blue"] * 5,
          "ambient_temp_lag_3": [np.nan, np.nan, np.nan, 31.31, 31.51],
          "module_temp_lag_3": [np.nan, np.nan, np.nan, 49.18, 49.84],
          "ambient_temp_lag_2": [np.nan, np.nan, 31.31, 31.51, 32.15],
          "module_temp_lag_2": [np.nan, np.nan, 49.18, 49.84, 52.35],
      }
      expected_results_df = pd.DataFrame(
          data=expected_results, index=date_time
      )
  
      # When period is an int.
      transformer = LagFeatures(
          variables=["ambient_temp", "module_temp"], periods=3
      )
      df_tr = transformer.fit_transform(df_time)
      assert df_tr.head(5).equals(
          expected_results_df.drop(
              ["ambient_temp_lag_2", "module_temp_lag_2"], axis=1
          )
      )
  
      # When period is list.
      transformer = LagFeatures(
          variables=["ambient_temp", "module_temp"], periods=[3, 2]
      )
      df_tr = transformer.fit_transform(df_time)
      assert df_tr.head(5).equals(expected_results_df)
  
      # When drop original is True
      transformer = LagFeatures(
          variables=["ambient_temp", "module_temp"],
          periods=[3, 2],
          drop_original=True,
      )
      df_tr = transformer.fit_transform(df_time)
      assert df_tr.head(5).equals(
          expected_results_df.drop(
              ["ambient_temp", "module_temp"], axis=1
          )
      )
  
file_path: feature_engine/tests/test_time_series/test_forecasting/test_lag_features.py
imports: import numpy
  import pandas
  import pytest
  from feature_engine.timeseries.forecasting import LagFeatures
label_desc: Use image node_id 7 for calling a global function with example usage: test_correct_lag_when_using_periods(df_time) without return types