code: def to_xyz(self, buf=None, sort_index=True,
                 index=False, header=False, float_format='{:.6f}'.format,
                 overwrite=True):
          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)
          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