Skip to content

Table of Contents

t3co/utils/print_class_objects

obj_to_string

Python
def obj_to_string(obj: Union[object, List[object]],
                  extra: str = "    ") -> str

Converts an object or list of objects to a formatted string representation.

Arguments:

  • obj Union[object, List[object]] - The object or list of objects to convert.
  • extra str, optional - Indentation string for nested objects. Defaults to " ".

Returns:

  • str - Formatted string representation of the object.

handle_nan

Python
def handle_nan(
        obj: Union[float, dict, list]) -> Union[None, dict, list, float]

Replaces NaN values in an object with None.

Arguments:

  • obj Union[float, dict, list] - The object to process.

Returns:

Union[None, dict, list, float]: The processed object with NaN values replaced by None.

custom_default

Python
def custom_default(obj: object) -> Union[None, dict, str]

Custom default function for JSON serialization.

Arguments:

  • obj object - The object to serialize.

Returns:

Union[None, dict, str]: The serialized object.

to_flat_dict

Python
def to_flat_dict(obj: object,
                 include_predix: bool = True,
                 prefix: str = "",
                 delimiter: str = "_") -> dict

Flattens a nested object into a dictionary.

Arguments:

  • obj object - The object to flatten.
  • include_predix bool, optional - Whether to include the prefix in the keys. Defaults to True.
  • prefix str, optional - The prefix for the keys. Defaults to "".
  • delimiter str, optional - The delimiter for the keys. Defaults to "_".

Returns:

  • dict - The flattened dictionary.

remove_df_attrs

Python
def remove_df_attrs(obj: object) -> None

Removes DataFrame attributes from an object.

Arguments:

  • obj object - The object to process.