code: def export_to_netcdf(network, path=None, export_standard_types=False,
                       least_significant_digit=None):
      
  
      assert has_xarray, "xarray must be installed for netCDF support."
  
      basename = os.path.basename(path) if path is not None else None
      with ExporterNetCDF(path, least_significant_digit) as exporter:
          _export_to_exporter(network, exporter, basename=basename,
                              export_standard_types=export_standard_types)
          return exporter.ds
docs: Export network and components to a netCDF file.
  
      Both static and series attributes of components are exported, but only
      if they have non-default values.
  
      If path does not already exist, it is created.
  
      If no path is passed, no file is exported, but the xarray.Dataset
      is still returned.
  
      Be aware that this cannot export boolean attributes on the Network
      class, e.g. network.my_bool = False is not supported by netCDF.
  
      Parameters
      ----------
      path : string|None
          Name of netCDF file to which to export (if it exists, it is overwritten);
          if None is passed, no file is exported.
      least_significant_digit
          This is passed to the netCDF exporter, but currently makes no difference
          to file size or float accuracy. We're working on improving this...
  
      Returns
      -------
      ds : xarray.Dataset
  
      Examples
      --------
      >>> export_to_netcdf(network, "my_file.nc")
      OR
      >>> network.export_to_netcdf("my_file.nc")