๐พ 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}")
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")
- 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")
- 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
...