def subset(df, items, axis=1):
  """
  Constructs a dataframe is a subset to the items, by row or column.

  Parameters
  ----------
  df: pd.DataFrame
  items: list
      columns if axis = 1
      indices if axis = 0
  axis: int
      0 - rows
      1 - columns
  
  Returns
  -------
  pd.DataFrame
  """
  if axis == 1:
    columns = list(set(items).intersection(df.columns))
    return df[columns]
  elif axis == 0:
    indices = list(set(items).intersection(df.index))
    return df.loc[indices, :]
  else:
    raise ValueError("Invalid axis: %d" % axis)