nodes: 0, module; 1, function_definition; 2, function_name:to_xyz; 3, parameters; 4, block; 5, identifier:self; 6, default_parameter; 7, default_parameter; 8, default_parameter; 9, default_parameter; 10, default_parameter; 11, default_parameter; 12, expression_statement; 13, if_statement; 14, comment:# NOTE the following might be removed in the future; 15, comment:# introduced because of formatting bug in pandas; 16, comment:# See https://github.com/pandas-dev/pandas/issues/13032; 17, expression_statement; 18, expression_statement; 19, if_statement; 20, identifier:buf; 21, None; 22, identifier:sort_index; 23, True; 24, identifier:index; 25, False; 26, identifier:header; 27, False; 28, identifier:float_format; 29, attribute; 30, identifier:overwrite; 31, True; 32, comment:"""Write xyz-file
  
          Args:
              buf (str): StringIO-like, optional buffer to write to
              sort_index (bool): If sort_index is true, the
                  :class:`~chemcoord.Cartesian`
                  is sorted by the index before writing.
              float_format (one-parameter function): Formatter function
                  to apply to column’s elements if they are floats.
                  The result of this function must be a unicode string.
              overwrite (bool): May overwrite existing files.
  
          Returns:
              formatted : string (or unicode, depending on data and options)
          """; 33, identifier:sort_index; 34, block; 35, else_clause; 36, assignment; 37, assignment; 38, comparison_operator:buf is not None; 39, block; 40, else_clause; 41, string; 42, identifier:format; 43, expression_statement; 44, block; 45, identifier:space; 46, binary_operator:' ' * (self.loc[:, 'atom'].str.len().max()
                         - len(self.iloc[0, 0])); 47, identifier:output; 48, call; 49, identifier:buf; 50, None; 51, if_statement; 52, block; 53, string_content:{:.6f}; 54, assignment; 55, expression_statement; 56, string; 57, parenthesized_expression; 58, attribute; 59, argument_list; 60, identifier:overwrite; 61, block; 62, else_clause; 63, return_statement; 64, identifier:molecule_string; 65, call; 66, assignment; 67, string_content:; 68, binary_operator:self.loc[:, 'atom'].str.len().max()
                         - len(self.iloc[0, 0]); 69, string; 70, identifier:format; 71, keyword_argument; 72, keyword_argument; 73, keyword_argument; 74, keyword_argument; 75, with_statement; 76, block; 77, identifier:output; 78, attribute; 79, argument_list; 80, identifier:molecule_string; 81, call; 82, call; 83, call; 84, string_content; 85, identifier:n; 86, call; 87, identifier:alignment; 88, identifier:space; 89, identifier:frame_string; 90, identifier:molecule_string; 91, identifier:message; 92, string; 93, with_clause; 94, block; 95, with_statement; 96, call; 97, identifier:to_string; 98, keyword_argument; 99, keyword_argument; 100, keyword_argument; 101, attribute; 102, argument_list; 103, attribute; 104, argument_list; 105, identifier:len; 106, argument_list; 107, escape_sequence:\n; 108, escape_sequence:\n; 109, identifier:len; 110, argument_list; 111, string_content:Created by chemcoord http://chemcoord.readthedocs.io/; 112, with_item; 113, expression_statement; 114, with_clause; 115, block; 116, attribute; 117, argument_list; 118, identifier:header; 119, identifier:header; 120, identifier:index; 121, identifier:index; 122, identifier:float_format; 123, identifier:float_format; 124, identifier:self; 125, identifier:to_string; 126, keyword_argument; 127, keyword_argument; 128, keyword_argument; 129, call; 130, identifier:max; 131, subscript; 132, identifier:self; 133, as_pattern; 134, call; 135, with_item; 136, expression_statement; 137, identifier:self; 138, identifier:sort_index; 139, identifier:header; 140, identifier:header; 141, identifier:index; 142, identifier:index; 143, identifier:float_format; 144, identifier:float_format; 145, attribute; 146, argument_list; 147, attribute; 148, integer:0; 149, integer:0; 150, call; 151, as_pattern_target; 152, attribute; 153, argument_list; 154, as_pattern; 155, call; 156, attribute; 157, identifier:len; 158, identifier:self; 159, identifier:iloc; 160, identifier:open; 161, argument_list; 162, identifier:f; 163, identifier:f; 164, identifier:write; 165, identifier:output; 166, call; 167, as_pattern_target; 168, attribute; 169, argument_list; 170, subscript; 171, identifier:str; 172, identifier:buf; 173, keyword_argument; 174, identifier:open; 175, argument_list; 176, identifier:f; 177, identifier:f; 178, identifier:write; 179, identifier:output; 180, attribute; 181, slice; 182, string; 183, identifier:mode; 184, string; 185, identifier:buf; 186, keyword_argument; 187, identifier:self; 188, identifier:loc; 189, string_content:atom; 190, string_content:w; 191, identifier:mode; 192, string; 193, string_content:x
code: def to_xyz(self, buf=None, sort_index=True,
                 index=False, header=False, float_format='{:.6f}'.format,
                 overwrite=True):
          """Write xyz-file
  
          Args:
              buf (str): StringIO-like, optional buffer to write to
              sort_index (bool): If sort_index is true, the
                  :class:`~chemcoord.Cartesian`
                  is sorted by the index before writing.
              float_format (one-parameter function): Formatter function
                  to apply to column’s elements if they are floats.
                  The result of this function must be a unicode string.
              overwrite (bool): May overwrite existing files.
  
          Returns:
              formatted : string (or unicode, depending on data and options)
          """
          if sort_index:
              molecule_string = self.sort_index().to_string(
                  header=header, index=index, float_format=float_format)
          else:
              molecule_string = self.to_string(header=header, index=index,
                                               float_format=float_format)
  
          # NOTE the following might be removed in the future
          # introduced because of formatting bug in pandas
          # See https://github.com/pandas-dev/pandas/issues/13032
          space = ' ' * (self.loc[:, 'atom'].str.len().max()
                         - len(self.iloc[0, 0]))
  
          output = '{n}\n{message}\n{alignment}{frame_string}'.format(
              n=len(self), alignment=space, frame_string=molecule_string,
              message='Created by chemcoord http://chemcoord.readthedocs.io/')
  
          if buf is not None:
              if overwrite:
                  with open(buf, mode='w') as f:
                      f.write(output)
              else:
                  with open(buf, mode='x') as f:
                      f.write(output)
          else:
              return output