nodes: 0, module; 1, function_definition; 2, function_name:to_dask_dataframe; 3, parameters; 4, block; 5, identifier:self; 6, default_parameter; 7, default_parameter; 8, expression_statement; 9, import_statement; 10, import_statement; 11, if_statement; 12, expression_statement; 13, expression_statement; 14, expression_statement; 15, expression_statement; 16, expression_statement; 17, for_statement; 18, expression_statement; 19, if_statement; 20, return_statement; 21, identifier:dim_order; 22, None; 23, identifier:set_index; 24, False; 25, comment:"""
          Convert this dataset into a dask.dataframe.DataFrame.
  
          The dimensions, coordinates and data variables in this dataset form
          the columns of the DataFrame.
  
          Parameters
          ----------
          dim_order : list, optional
              Hierarchical dimension order for the resulting dataframe. All
              arrays are transposed to this order and then written out as flat
              vectors in contiguous order, so the last dimension in this list
              will be contiguous in the resulting DataFrame. This has a major
              influence on which operations are efficient on the resulting dask
              dataframe.
  
              If provided, must include all dimensions on this dataset. By
              default, dimensions are sorted alphabetically.
          set_index : bool, optional
              If set_index=True, the dask DataFrame is indexed by this dataset's
              coordinate. Since dask DataFrames to not support multi-indexes,
              set_index only works if the dataset only contains one dimension.
  
          Returns
          -------
          dask.dataframe.DataFrame
          """; 26, aliased_import; 27, aliased_import; 28, comparison_operator:dim_order is None; 29, block; 30, elif_clause; 31, assignment; 32, assignment; 33, call; 34, call; 35, assignment; 36, identifier:name; 37, identifier:columns; 38, block; 39, assignment; 40, identifier:set_index; 41, block; 42, identifier:df; 43, dotted_name; 44, identifier:da; 45, dotted_name; 46, identifier:dd; 47, identifier:dim_order; 48, None; 49, expression_statement; 50, comparison_operator:set(dim_order) != set(self.dims); 51, block; 52, identifier:ordered_dims; 53, call; 54, identifier:columns; 55, call; 56, attribute; 57, generator_expression; 58, attribute; 59, argument_list; 60, identifier:series_list; 61, list; 62, try_statement; 63, comment:# IndexVariable objects have a dummy .chunk() method; 64, if_statement; 65, expression_statement; 66, expression_statement; 67, expression_statement; 68, identifier:df; 69, call; 70, if_statement; 71, identifier:dask; 72, identifier:array; 73, identifier:dask; 74, identifier:dataframe; 75, assignment; 76, call; 77, call; 78, raise_statement; 79, identifier:OrderedDict; 80, generator_expression; 81, identifier:list; 82, argument_list; 83, identifier:columns; 84, identifier:extend; 85, identifier:k; 86, for_in_clause; 87, if_clause; 88, identifier:columns; 89, identifier:extend; 90, attribute; 91, block; 92, except_clause; 93, call; 94, block; 95, assignment; 96, assignment; 97, call; 98, attribute; 99, argument_list; 100, comparison_operator:len(dim_order) == 1; 101, block; 102, else_clause; 103, identifier:dim_order; 104, call; 105, identifier:set; 106, argument_list; 107, identifier:set; 108, argument_list; 109, call; 110, tuple; 111, for_in_clause; 112, identifier:ordered_dims; 113, identifier:k; 114, attribute; 115, comparison_operator:k not in self.dims; 116, identifier:self; 117, identifier:data_vars; 118, expression_statement; 119, identifier:KeyError; 120, comment:# dimension without a matching coordinate; 121, block; 122, identifier:isinstance; 123, argument_list; 124, expression_statement; 125, identifier:dask_array; 126, attribute; 127, identifier:series; 128, call; 129, attribute; 130, argument_list; 131, identifier:dd; 132, identifier:concat; 133, identifier:series_list; 134, keyword_argument; 135, call; 136, integer:1; 137, expression_statement; 138, expression_statement; 139, comment:# triggers an error about multi-indexes, even if only one; 140, comment:# dimension is passed; 141, block; 142, identifier:list; 143, argument_list; 144, identifier:dim_order; 145, attribute; 146, identifier:ValueError; 147, argument_list; 148, identifier:k; 149, subscript; 150, identifier:k; 151, identifier:dim_order; 152, identifier:self; 153, identifier:coords; 154, identifier:k; 155, attribute; 156, assignment; 157, expression_statement; 158, expression_statement; 159, expression_statement; 160, identifier:var; 161, identifier:IndexVariable; 162, assignment; 163, call; 164, identifier:data; 165, attribute; 166, argument_list; 167, identifier:series_list; 168, identifier:append; 169, identifier:series; 170, identifier:axis; 171, integer:1; 172, identifier:len; 173, argument_list; 174, assignment; 175, assignment; 176, expression_statement; 177, attribute; 178, identifier:self; 179, identifier:dims; 180, call; 181, attribute; 182, identifier:k; 183, identifier:self; 184, identifier:dims; 185, identifier:var; 186, subscript; 187, assignment; 188, assignment; 189, assignment; 190, identifier:var; 191, call; 192, attribute; 193, argument_list; 194, identifier:dd; 195, identifier:from_array; 196, call; 197, keyword_argument; 198, identifier:dim_order; 199, tuple_pattern; 200, identifier:dim_order; 201, identifier:df; 202, call; 203, assignment; 204, identifier:self; 205, identifier:dims; 206, attribute; 207, argument_list; 208, identifier:self; 209, identifier:dims; 210, attribute; 211, identifier:name; 212, identifier:size; 213, subscript; 214, identifier:data; 215, call; 216, identifier:var; 217, call; 218, attribute; 219, argument_list; 220, call; 221, identifier:chunk; 222, attribute; 223, attribute; 224, argument_list; 225, identifier:columns; 226, list; 227, identifier:dim; 228, attribute; 229, argument_list; 230, identifier:df; 231, call; 232, concatenated_string; 233, identifier:format; 234, identifier:dim_order; 235, call; 236, identifier:self; 237, identifier:variables; 238, attribute; 239, identifier:name; 240, attribute; 241, argument_list; 242, identifier:Variable; 243, argument_list; 244, identifier:var; 245, identifier:to_base_variable; 246, attribute; 247, argument_list; 248, identifier:self; 249, identifier:chunks; 250, identifier:dask_array; 251, identifier:reshape; 252, unary_operator; 253, identifier:name; 254, identifier:df; 255, identifier:set_index; 256, identifier:dim; 257, attribute; 258, argument_list; 259, string; 260, string; 261, identifier:list; 262, argument_list; 263, identifier:self; 264, identifier:dims; 265, identifier:da; 266, identifier:arange; 267, identifier:size; 268, keyword_argument; 269, keyword_argument; 270, tuple; 271, identifier:data; 272, identifier:var; 273, identifier:set_dims; 274, identifier:ordered_dims; 275, integer:1; 276, identifier:df; 277, identifier:set_index; 278, identifier:dim_order; 279, string_content:dim_order {} does not match the set of dimensions on this; 280, string_content:Dataset: {}; 281, attribute; 282, identifier:chunks; 283, identifier:size; 284, identifier:dtype; 285, attribute; 286, identifier:name; 287, identifier:self; 288, identifier:dims; 289, identifier:np; 290, identifier:int64
code: def to_dask_dataframe(self, dim_order=None, set_index=False):
          """
          Convert this dataset into a dask.dataframe.DataFrame.
  
          The dimensions, coordinates and data variables in this dataset form
          the columns of the DataFrame.
  
          Parameters
          ----------
          dim_order : list, optional
              Hierarchical dimension order for the resulting dataframe. All
              arrays are transposed to this order and then written out as flat
              vectors in contiguous order, so the last dimension in this list
              will be contiguous in the resulting DataFrame. This has a major
              influence on which operations are efficient on the resulting dask
              dataframe.
  
              If provided, must include all dimensions on this dataset. By
              default, dimensions are sorted alphabetically.
          set_index : bool, optional
              If set_index=True, the dask DataFrame is indexed by this dataset's
              coordinate. Since dask DataFrames to not support multi-indexes,
              set_index only works if the dataset only contains one dimension.
  
          Returns
          -------
          dask.dataframe.DataFrame
          """
  
          import dask.array as da
          import dask.dataframe as dd
  
          if dim_order is None:
              dim_order = list(self.dims)
          elif set(dim_order) != set(self.dims):
              raise ValueError(
                  'dim_order {} does not match the set of dimensions on this '
                  'Dataset: {}'.format(dim_order, list(self.dims)))
  
          ordered_dims = OrderedDict((k, self.dims[k]) for k in dim_order)
  
          columns = list(ordered_dims)
          columns.extend(k for k in self.coords if k not in self.dims)
          columns.extend(self.data_vars)
  
          series_list = []
          for name in columns:
              try:
                  var = self.variables[name]
              except KeyError:
                  # dimension without a matching coordinate
                  size = self.dims[name]
                  data = da.arange(size, chunks=size, dtype=np.int64)
                  var = Variable((name,), data)
  
              # IndexVariable objects have a dummy .chunk() method
              if isinstance(var, IndexVariable):
                  var = var.to_base_variable()
  
              dask_array = var.set_dims(ordered_dims).chunk(self.chunks).data
              series = dd.from_array(dask_array.reshape(-1), columns=[name])
              series_list.append(series)
  
          df = dd.concat(series_list, axis=1)
  
          if set_index:
              if len(dim_order) == 1:
                  (dim,) = dim_order
                  df = df.set_index(dim)
              else:
                  # triggers an error about multi-indexes, even if only one
                  # dimension is passed
                  df = df.set_index(dim_order)
  
          return df