Skip to content

🧱 ExportableMixin Utility

ExportMixin

METHOD DESCRIPTION
export
to_dataframe

Convert the response data collection to a Pandas DataFrame.

summary

Build, optionally print, and optionally save an analytics summary of the dataset.

export(filename: str = 'doge_data', format: str = 'csv') -> Path

to_dataframe(parse_dates: bool = True) -> pd.DataFrame

Convert the response data collection to a Pandas DataFrame.

PARAMETER DESCRIPTION

parse_dates

If True, coerce known date columns (date, payment_date, deleted_date) from date strings to datetime64. Unparseable values become NaT. Set False to keep the raw string columns.

TYPE: bool DEFAULT: True

RETURNS DESCRIPTION
DataFrame

summary(verbose: bool = False, save_as: Optional[str] = None, to_stdout: bool = True) -> str

Build, optionally print, and optionally save an analytics summary of the dataset.

PARAMETER DESCRIPTION

verbose

If True, include a head preview of the data.

TYPE: bool DEFAULT: False

save_as

Path to save the summary text (e.g. "summary.md" or "report.txt").

TYPE: str DEFAULT: None

to_stdout

If True, print the summary to stdout. Set False to capture it silently via the return value.

TYPE: bool DEFAULT: True

RETURNS DESCRIPTION
str

The rendered summary text.


🔁 Utility Functions

handle_dict

handle_dict(obj)

Source code in src/pydoge_api/utils/exporter.py
Python
def handle_dict(obj):
    if isinstance(obj, dict) and not hasattr(obj, "export"):
        new_obj = DictExportable(**obj)
        return new_obj
    return obj

This ensures that even raw dict responses support .export().


DictExportable

DictExportable

Bases: dict, ExportMixin

A dict subclass with .export() support

A subclass of dict that supports .export(), .to_dataframe(), .summary(). Used when output_pydantic=False.