class_docstr: A flow to generate some statistics about the movie genres.
  
  The flow performs the following steps:
  1) Ingests a CSV into a dataframe.
  2) Fan-out over genre using Metaflow foreach.
  3) Compute quartiles for each genre.
  4) Save a dictionary of genre-specific statistics.
docstr: Compute statistics for a single genre.
docstr_tok: ["Compute","statistics","for","a","single","genre","."]
code: def compute_statistics(self):
      """
      Compute statistics for a single genre.
      """
  
      # The genre currently being processed is a class property called
      # 'input'.
      self.genre = self.input
      print("Computing statistics for %s" % self.genre)
  
      # Find all the movies that have this genre and build a dataframe with
      # just those movies and just the columns of interest.
      selector = [self.genre in row for row in self.dataframe["genres"]]
  
      for col in self.dataframe.keys():
          self.dataframe[col] = [
              col
              for col, is_genre in zip(self.dataframe[col], selector)
              if is_genre
          ]
  
      # Sort by gross box office and drop unused column.
      argsort_indices = sorted(
          range(len(self.dataframe["gross"])),
          key=self.dataframe["gross"].__getitem__,
      )
      for col in self.dataframe.keys():
          self.dataframe[col] = [
              self.dataframe[col][idx] for idx in argsort_indices
          ]
      del self.dataframe["title_year"]
  
      # Get some statistics on the gross box office for these titles.
      n_points = len(self.dataframe["movie_title"])
      self.quartiles = []
      for cut in [0.25, 0.5, 0.75]:
          idx = 0 if n_points < 2 else round(n_points * cut)
          self.quartiles.append(self.dataframe["gross"][idx])
  
      # Join the results from other genres.
      self.next(self.join)
  
file_path: metaflow/metaflow/tutorials/02-statistics/stats.py
imports: from metaflow import FlowSpec, step, IncludeFile
label_desc: Use image node_id 2 for calling the MovieStatsFlow obj's underlying member method code with example usage: obj.compute_statistics() without return types