quantlab.acquisition.fred.parse_csv#

quantlab.acquisition.fred.parse_csv(text, series)[source]#

Return (timestamp, value) rows of one FRED CSV answer.

Parameters:
textstr

The response body.

seriesstr

The series id, which must head the value column.

Returns:
pl.DataFrame

timestamp (datetime) and value (float64, null where FRED has no observation).

Raises:
ValueError

If the answer is not two columns, the second named series, or a date is not YYYY-MM-DD.

Examples

>>> parse_csv("observation_date,DTB3\n2024-01-02,5.24\n2024-01-03,.\n", "DTB3")["value"].to_list()
[5.24, None]