domain_to_csv#
- domain_to_csv(domain, name_of_file=None, path_to_save=None, save_summary=True, return_dataframe=False)#
Export a domain object as a CSV file. All object properties will be saved as columns in the CSV file including labels and collections associated with the object. Optionally, the function can return the pandas dataframe that was saved to the CSV file. If the domain contains shape objects, the dataframe will include the vertices of the shapes instead of the shape centroids. There will be an additional column ‘hole_id’ to identify vertices that belong to internal holes of shapes.
- Parameters:
- domainmuspan.domain
The domain object to be exported as csv.
- name_of_filestr or None, optional
The name of the saved csv file. If None, the domain’s name will be used. Default is None.
- path_to_savestr or None, optional
The path to the folder where the file will be saved. If None, the current directory will be used. Default is None.
- save_summarybool, optional
If True, a summary message will be printed after saving the file. Default is True.
- return_dataframebool, optional
If True, the pandas.dataframe will be returned. Default is False.
- Returns:
- pandas.DataFrame
The dataframe that was saved to the CSV file. Only returned if return_df is True.
- Raises:
- ValueError
If domain is not of type
muspan.domain. If path_to_save is not a string or None. If name_of_file is not a string or None.
Examples
import muspan as ms # load an example domain example_domain = ms.datasets.load_example_domain('Xenium-Healthy-Colon') # save the domain locally to the current working directory with a specified file name path_to_save = '.' name_of_file = 'saved_example_domain.csv' # save the domain ms.io.domain_to_csv(example_domain, name_of_file=name_of_file, path_to_save=path_to_save)