docstr: Test get_clean_factor_and_forward_returns on an event
docstr_tok: ["Test","get_clean_factor_and_forward_returns","on","an","event"]
code: def test_get_clean_factor_and_forward_returns_4(self):
      """
      Test get_clean_factor_and_forward_returns on an event
      """
      tickers = ["A", "B", "C", "D", "E", "F"]
  
      factor_groups = {"A": 1, "B": 2, "C": 1, "D": 2, "E": 1, "F": 2}
  
      price_data = [
          [
              1.10**i,
              0.50**i,
              3.00**i,
              0.90**i,
              0.50**i,
              1.00**i,
          ]
          for i in range(1, 9)
      ]
  
      factor_data = [
          [1, nan, nan, nan, nan, 6],
          [4, nan, nan, 7, nan, nan],
          [nan, nan, nan, nan, nan, nan],
          [nan, 3, nan, 2, nan, nan],
          [nan, nan, 1, nan, 3, nan],
      ]
  
      price_index = date_range(
          start="2017-1-12", end="2017-1-23", freq="B"
      )
      price_index.name = "date"
      prices = DataFrame(
          index=price_index, columns=tickers, data=price_data
      )
  
      factor_index = date_range(
          start="2017-1-12", end="2017-1-18", freq="B"
      )
      factor_index.name = "date"
      factor = DataFrame(
          index=factor_index, columns=tickers, data=factor_data
      ).stack()
  
      factor_data = get_clean_factor_and_forward_returns(
          factor,
          prices,
          groupby=factor_groups,
          quantiles=4,
          periods=(1, 2, 3),
      )
  
      expected_idx = factor.index.rename(["date", "asset"])
      expected_cols = [
          "1D",
          "2D",
          "3D",
          "factor",
          "group",
          "factor_quantile",
      ]
      expected_data = [
          [0.1, 0.21, 0.331, 1.0, 1, 1],
          [0.0, 0.00, 0.000, 6.0, 2, 4],
          [0.1, 0.21, 0.331, 4.0, 1, 1],
          [-0.1, -0.19, -0.271, 7.0, 2, 4],
          [-0.5, -0.75, -0.875, 3.0, 2, 4],
          [-0.1, -0.19, -0.271, 2.0, 2, 1],
          [2.0, 8.00, 26.000, 1.0, 1, 1],
          [-0.5, -0.75, -0.875, 3.0, 1, 4],
      ]
      expected = DataFrame(
          index=expected_idx, columns=expected_cols, data=expected_data
      )
      expected["group"] = expected["group"].astype("category")
  
      assert_frame_equal(factor_data, expected)
  
file_path: alphalens/alphalens/tests/test_utils.py
imports: from __future__ import division
  from unittest import TestCase
  from parameterized import parameterized
  from numpy import nan
  from pandas import Series, DataFrame, date_range, MultiIndex, Timedelta, Timestamp, concat
  from pandas.util.testing import assert_frame_equal, assert_series_equal
  from ..utils import get_clean_factor_and_forward_returns, compute_forward_returns, quantize_factor
label_desc: Use image node_id 8 for calling the UtilsTestCase obj's underlying member method code with example usage: obj.test_get_clean_factor_and_forward_returns_4() without return types