tf_quant_finance.datetime.convert_to_date_tensor

Last updated: 2023-03-16.

tf_quant_finance.datetime.convert_to_date_tensor#

View source

Converts supplied data to a DateTensor if possible.

tf_quant_finance.datetime.convert_to_date_tensor(
    date_inputs
)

Args:#

  • date_inputs: One of the supported types that can be converted to a DateTensor. The following input formats are supported. 1. Sequence of datetime.datetime, datetime.date, or any other structure with data attributes called ‘year’, ‘month’ and ‘day’. 2. A numpy array of datetime64 type. 3. Sequence of (year, month, day) Tuples. Months are 1-based (with January as 1) and constants.Months enum may be used instead of ints. Days are also 1-based. 4. A tuple of three int32 Tensors containing year, month and date as positive integers in that order. 5. A single int32 Tensor containing ordinals (i.e. number of days since 31 Dec 0 with 1 being 1 Jan 1.)

Returns:#

A DateTensor object representing the supplied dates.

Raises:#

  • ValueError: If conversion fails for any reason.