def keep_rows_by_multi_index(df, multi_index_name, multi_index_value):
  """Keeps rows with given multi-index values from a DataFrame.

  Args:
    df: DataFrame with samples as rows and multi-indices.
    multi_index_name: String, the name of the multi-index.
    multi_index_value: String or a list of strings, the values of the
      multi-index.

  Returns:
    A subset of the DataFrame with only the specified rows.

  Raises:
    ValueError: Multi-index to drop is not contained in the DataFrame.
  """
  if multi_index_name not in df.index.names:
    raise ValueError(
        'Multi-index %s is not contained in the DataFrame.' % multi_index_name)
  if not isinstance(multi_index_value, list):
    multi_index_value = [multi_index_value]
  return df[df.index.get_level_values(
      level=multi_index_name).isin(multi_index_value)]