Skip to content

Commit 72f3778

Browse files
author
The TensorFlow Datasets Authors
committed
Add sc:Time features to the CroissantBuilder.
PiperOrigin-RevId: 785417233
1 parent a26d6be commit 72f3778

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

tensorflow_datasets/core/dataset_builders/croissant_builder.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
from __future__ import annotations
3838

3939
from collections.abc import Mapping, Sequence
40+
import datetime
4041
import json
4142
from typing import Any
4243

@@ -169,8 +170,9 @@ def datatype_converter(
169170
feature = dtype_mapping[field_data_type]
170171
elif enp.lazy.is_np_dtype(field_data_type):
171172
feature = field_data_type
172-
# We return a text feature for mlc.DataType.DATE features.
173-
elif field_data_type == pd.Timestamp:
173+
# We return a text feature for mlc.DataType.DATE and mlc.DataType.TIME
174+
# features.
175+
elif field_data_type == pd.Timestamp or field_data_type == datetime.time:
174176
feature = text_feature.Text(doc=field.description)
175177
elif field_data_type == mlc.DataType.IMAGE_OBJECT:
176178
feature = image_feature.Image(doc=field.description)

tensorflow_datasets/core/dataset_builders/croissant_builder_test.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,11 @@ def test_bbox_datatype_converter_with_invalid_format():
165165
text_feature.Text,
166166
None,
167167
),
168+
(
169+
mlc.Field(data_types=mlc.DataType.TIME, description="Time feature"),
170+
text_feature.Text,
171+
None,
172+
),
168173
(
169174
mlc.Field(
170175
data_types=mlc.DataType.IMAGE_OBJECT,

0 commit comments

Comments
 (0)