metaspace_converter.utils module
- metaspace_converter.utils.empty_columns_to_nan(df)[source]
Converts all empty columns from None (dtype object) to NaN (dtype float).
- Parameters:
df (
DataFrame
) – A dataframe- Return type:
DataFrame
- Returns:
The modified dataframe. The original dataframe is modified, not a copy.
- metaspace_converter.utils.has_optical_image(dataset)[source]
Check whether a METASPACE dataset has an optical image
- Return type:
- metaspace_converter.utils.is_non_str_sequence(obj)[source]
Returns whether an object is a sequence (list and similar), excluding strings.
- metaspace_converter.utils.iter_property_paths(obj, delimiter='/', include_none=True, dont_traverse_types=(), dont_descend_paths=(), _path='')[source]
Iterates recursively over properties of nested objects.
- Parameters:
obj (
Any
) – A class instance, mapping or sequence.delimiter (
str
) – The delimiter to use. Should not be contained in any name.include_none (
bool
) – Whether to yield attributes which have None assigned, or skip them.dont_traverse_types (
tuple
[type
,...
]) – Iterable data types which should not be traversed any deeper. These are yielded as values.dont_descend_paths (
Collection
[str
]) – Paths with iterable objects that should be preserved.
- Return type:
- Returns:
An iterator for iterating over paths and objects found at each path. It can also be converted to a dictionary.
- metaspace_converter.utils.stringify_list_columns(df, columns=(), all=False)[source]
If the dataframe column is a list, stringify it into JSON.
- Parameters:
- Return type:
DataFrame
- Returns:
A dataframe where all values in specified columns are JSON stringified.