Skip to content

๐Ÿ’พ Exporting & Summarizing Data

Every response returned by the PyDoge SDK โ€” whether a Pydantic model or plain dictionary โ€” supports:

  • .export() โ€” Save data to CSV, Excel, or JSON
  • .to_dataframe() โ€” Get a Pandas DataFrame
  • .summary() โ€” Generate analytic summaries: rows, nulls, types, stats

These methods are available on all major responses: - Grants - Payments - Contracts - Leases


๐Ÿ“ค .export()

with DogeAPI(fetch_all=True) as api:
    grants = api.savings.get_grants()
    path = grants.export("grants_q1", format="csv")
    print(f"Saved to: {path}")
This saves a timestamped file like:

grants_q2_20250410_172308.csv

Supported Formats - csv โ†’ grants_q1_YYYYMMDD_HHMMSS.csv - xlsx โ†’ Excel spreadsheet - json โ†’ JSON array (records-style)

๐Ÿ“Š .to_dataframe()

Convert any result into a Pandas DataFrame for analysis:

with DogeAPI() as api:
    df = api.savings.get_contracts().to_dataframe()
    print(df.head())
    print(df.shape)
    df.plot("date_closed", "savings")
This is helpful for:

  • Analytics
  • Plotting
  • Custom filters

๐Ÿ“ˆ .summary(verbose=True)

Get a full analytical breakdown of your dataset:

with DogeAPI() as api:
    grants.summary()

    # Show summary in terminal
    grants.summary(verbose=True)

    # Save the summary as markdown
    grants.summary(save_as="logs/grants_summary.md")
Output:

  • Total rows and columns
  • Nulls by column
  • Dtypes
  • Numeric stats (mean, min, max)
  • Top categories
  • Optional .head() preview

๐Ÿงช Example Output

๐Ÿ“Š PyDoge Data Summary
========================================
๐Ÿงพ Rows       : 2450
๐Ÿงฌ Columns    : 8
๐Ÿ•ณ๏ธ  Total NaNs : 17

๐Ÿ“‘ Column Data Types:
id              int64
agency         object
savings       float64

๐Ÿ“‰ Nulls by Column:
savings     7
status      10

๐Ÿ“ˆ Numeric Column Stats:
         count      mean      std     min       max
savings  2443.0  151234.3  98231.4  100.0   998500.0

๐Ÿ”  Top Categories:
[status]
completed     1300
cancelled      900
pending        250

๐Ÿ“‹ Sample Preview:
   id agency status savings
0   1   NASA   completed  100000.0
...