DataTypes#
daft.DataType#
Daft provides simple DataTypes that are ubiquitous in many DataFrames such as numbers, strings and dates - all the way up to more complex types like tensors and images.
DataType #
DataType()
A Daft DataType defines the type of all the values in an Expression or DataFrame column.
Methods:
| Name | Description |
|---|---|
decimal128 | Fixed-precision decimal. |
duration | Duration DataType. |
embedding | Create an Embedding DataType: embeddings are fixed size arrays, where each element in the array has a numeric |
extension | |
file | Create a File DataType: a type which refers to a file object. |
fixed_size_binary | Create a FixedSizeBinary DataType: A fixed-size string of bytes. |
fixed_size_list | Create a FixedSizeList DataType: Fixed-size list, where each element in the list has type |
from_arrow_type | Maps a PyArrow DataType to a Daft DataType. |
from_numpy_dtype | Maps a Numpy datatype to a Daft DataType. |
from_sql | Construct a Daft DataType from a SQL type. |
image | Create an Image DataType: image arrays contain (height, width, channel) ndarrays of pixel values. |
infer_from_object | Infer Daft DataType from a Python object. |
infer_from_type | Infer Daft DataType from a Python type. |
is_binary | Check if this is a binary type. |
is_boolean | Check if this is a boolean type. |
is_date | Check if this is a date type. |
is_decimal128 | Check if this is a decimal128 type. |
is_duration | Check if this is a duration type. |
is_embedding | Check if this is an embedding type. |
is_extension | Check if this is an extension type. |
is_file | Check if this is a file type. |
is_fixed_shape_image | Check if this is a fixed shape image type. |
is_fixed_shape_sparse_tensor | Check if this is a fixed shape sparse tensor type. |
is_fixed_shape_tensor | Check if this is a fixed shape tensor type. |
is_fixed_size_binary | Check if this is a fixed size binary type. |
is_fixed_size_list | Check if this is a fixed size list type. |
is_float16 | Check if this is a 16-bit float type. |
is_float32 | Check if this is a 32-bit float type. |
is_float64 | Check if this is a 64-bit float type. |
is_image | Check if this is an image type. |
is_int16 | Check if this is a 16-bit integer type. |
is_int32 | Check if this is a 32-bit integer type. |
is_int64 | Check if this is a 64-bit integer type. |
is_int8 | Check if this is an 8-bit integer type. |
is_integer | Check if this is an integer type. |
is_interval | Check if this is an interval type. |
is_list | Check if this is a list type. |
is_logical | Check if this is a logical type. |
is_map | Check if this is a map type. |
is_null | Check if this is a null type. |
is_numeric | Check if this is a numeric type. |
is_python | Check if this is a python object type. |
is_sparse_tensor | Check if this is a sparse tensor type. |
is_string | Check if this is a string type. |
is_struct | Check if this is a struct type. |
is_temporal | Check if this is a temporal type. |
is_tensor | Check if this is a tensor type. |
is_time | Check if this is a time type. |
is_timestamp | Check if this is a timestamp type. |
is_uint16 | Check if this is an unsigned 16-bit integer type. |
is_uint32 | Check if this is an unsigned 32-bit integer type. |
is_uint64 | Check if this is an unsigned 64-bit integer type. |
is_uint8 | Check if this is an unsigned 8-bit integer type. |
is_union | Check if this is a union type. |
is_uuid | Check if this is a UUID type. |
list | Create a List DataType: Variable-length list, where each element in the list has type |
map | Create a Map DataType: A map is a nested type of key-value pairs that is implemented as a list of structs with two fields, key and value. |
sparse_tensor | Create a SparseTensor DataType: SparseTensor arrays implemented as 'COO Sparse Tensor' representation of n-dimensional arrays of data of the provided |
struct | Create a Struct DataType: a nested type which has names mapped to child types. |
tensor | Create a tensor DataType: tensor arrays contain n-dimensional arrays of data of the provided |
time | Time DataType. Supported timeunits are "us", "ns". |
timestamp | Timestamp DataType. |
to_arrow_dtype | |
union | Create a Union DataType: a union of named fields, each with its own type. |
Attributes:
| Name | Type | Description |
|---|---|---|
binary | _CallableSingletonDataType | |
bool | _CallableSingletonDataType | |
date | _CallableSingletonDataType | |
dtype | DataType | If the datatype contains an inner type, return the inner type, otherwise an attribute error is raised. |
fields | dict[str, DataType] | If this is a struct type, return the fields, otherwise an attribute error is raised. |
float16 | _CallableSingletonDataType | |
float32 | _CallableSingletonDataType | |
float64 | _CallableSingletonDataType | |
image_mode | ImageMode | None | If this is an image type, return the (optional) image mode, otherwise an attribute error is raised. |
int16 | _CallableSingletonDataType | |
int32 | _CallableSingletonDataType | |
int64 | _CallableSingletonDataType | |
int8 | _CallableSingletonDataType | |
interval | _CallableSingletonDataType | |
key_type | DataType | If this is a map type, return the key type, otherwise an attribute error is raised. |
null | _CallableSingletonDataType | |
precision | int | If this is a decimal type, return the precision, otherwise an attribute error is raised. |
python | _CallableSingletonDataType | |
scale | int | If this is a decimal type, return the scale, otherwise an attribute error is raised. |
shape | tuple[int, ...] | If this is a fixed shape type, return the shape, otherwise an attribute error is raised. |
size | int | If this is a fixed size type, return the size, otherwise an attribute error is raised. |
string | _CallableSingletonDataType | |
timeunit | TimeUnit | If this is a time or timestamp type, return the timeunit, otherwise an attribute error is raised. |
timezone | str | None | If this is a timestamp type, return the timezone, otherwise an attribute error is raised. |
type_ids | list[int] | If this is a union type, return the type IDs, otherwise an attribute error is raised. |
uint16 | _CallableSingletonDataType | |
uint32 | _CallableSingletonDataType | |
uint64 | _CallableSingletonDataType | |
uint8 | _CallableSingletonDataType | |
union_fields | dict[str, DataType] | If this is a union type, return the fields, otherwise an attribute error is raised. |
union_mode | UnionMode | If this is a union type, return the union mode, otherwise an attribute error is raised. |
use_offset_indices | bool | If this is a sparse tensor type, return whether the indices are stored as offsets, otherwise an attribute error is raised. |
uuid | _CallableSingletonDataType | |
value_type | DataType | If this is a map type, return the value type, otherwise an attribute error is raised. |
Source code in daft/datatype.py
148 149 150 151 152 | |
dtype #
dtype: DataType
If the datatype contains an inner type, return the inner type, otherwise an attribute error is raised.
Examples:
1 2 3 4 5 6 7 8 | |
fields #
fields: dict[str, DataType]
If this is a struct type, return the fields, otherwise an attribute error is raised.
Examples:
1 2 3 4 5 6 7 8 9 | |
image_mode #
image_mode: ImageMode | None
If this is an image type, return the (optional) image mode, otherwise an attribute error is raised.
Examples:
1 2 3 4 5 6 7 8 | |
key_type #
key_type: DataType
If this is a map type, return the key type, otherwise an attribute error is raised.
Examples:
1 2 3 4 5 6 7 8 | |
precision #
precision: int
If this is a decimal type, return the precision, otherwise an attribute error is raised.
Examples:
1 2 3 4 5 6 7 8 | |
scale #
scale: int
If this is a decimal type, return the scale, otherwise an attribute error is raised.
Examples:
1 2 3 4 5 6 7 8 | |
shape #
shape: tuple[int, ...]
If this is a fixed shape type, return the shape, otherwise an attribute error is raised.
Examples:
1 2 3 4 5 6 7 8 | |
size #
size: int
If this is a fixed size type, return the size, otherwise an attribute error is raised.
Examples:
1 2 3 4 5 6 7 8 | |
timeunit #
timeunit: TimeUnit
If this is a time or timestamp type, return the timeunit, otherwise an attribute error is raised.
Examples:
1 2 3 4 5 6 7 8 | |
TimeUnit(ns) timezone #
timezone: str | None
If this is a timestamp type, return the timezone, otherwise an attribute error is raised.
Examples:
1 2 3 4 5 6 7 8 | |
type_ids #
type_ids: list[int]
If this is a union type, return the type IDs, otherwise an attribute error is raised.
Examples:
1 2 3 4 5 6 7 8 | |
union_fields #
union_fields: dict[str, DataType]
If this is a union type, return the fields, otherwise an attribute error is raised.
Examples:
1 2 3 4 5 6 7 8 9 | |
union_mode #
union_mode: UnionMode
If this is a union type, return the union mode, otherwise an attribute error is raised.
Examples:
1 2 3 4 5 6 7 8 | |
use_offset_indices #
use_offset_indices: bool
If this is a sparse tensor type, return whether the indices are stored as offsets, otherwise an attribute error is raised.
Examples:
1 2 3 4 5 6 7 8 | |
value_type #
value_type: DataType
If this is a map type, return the value type, otherwise an attribute error is raised.
Examples:
1 2 3 4 5 6 7 8 | |
decimal128 #
decimal128(precision: int, scale: int) -> DataType
Fixed-precision decimal.
Source code in daft/datatype.py
532 533 534 535 536 | |
duration #
duration(timeunit: TimeUnit | str) -> DataType
Duration DataType.
Source code in daft/datatype.py
554 555 556 557 558 559 560 | |
embedding #
Create an Embedding DataType: embeddings are fixed size arrays, where each element in the array has a numeric dtype and each array has a fixed length of size.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dtype | DataType | DataType of each element in the list (must be numeric) | required |
size | int | length of each list | required |
Source code in daft/datatype.py
614 615 616 617 618 619 620 621 622 623 624 625 | |
extension #
Source code in daft/datatype.py
609 610 611 612 | |
file #
file(media_type: MediaType = unknown()) -> DataType
Create a File DataType: a type which refers to a file object.
Source code in daft/datatype.py
859 860 861 862 863 | |
fixed_size_binary #
fixed_size_binary(size: int) -> DataType
Create a FixedSizeBinary DataType: A fixed-size string of bytes.
Source code in daft/datatype.py
524 525 526 527 528 529 530 | |
fixed_size_list #
Create a FixedSizeList DataType: Fixed-size list, where each element in the list has type dtype and each list has length size.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dtype | DataType | DataType of each element in the list | required |
size | int | length of each list | required |
Source code in daft/datatype.py
572 573 574 575 576 577 578 579 580 581 582 583 | |
from_arrow_type #
from_arrow_type(arrow_type: DataType, python_fallback: bool = True) -> DataType
Maps a PyArrow DataType to a Daft DataType.
Source code in daft/datatype.py
726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 | |
from_numpy_dtype #
from_numpy_dtype(np_type: dtype[Any]) -> DataType
Maps a Numpy datatype to a Daft DataType.
Source code in daft/datatype.py
849 850 851 852 853 | |
from_sql #
from_sql(sql_type: str) -> DataType
Construct a Daft DataType from a SQL type.
Source code in daft/datatype.py
494 495 496 497 | |
image #
image(mode: str | ImageMode | None = None, height: int | None = None, width: int | None = None) -> DataType
Create an Image DataType: image arrays contain (height, width, channel) ndarrays of pixel values.
Each image in the array has an :class:~daft.ImageMode, which describes the pixel dtype (e.g. uint8) and the number of image channels/bands and their logical interpretation (e.g. RGB).
If the height, width, and mode are the same for all images in the array, specifying them when constructing this type is advised, since that will allow Daft to create a more optimized physical representation of the image array.
If the height, width, or mode may vary across images in the array, leaving these fields unspecified when creating this type will cause Daft to represent this image array as a heterogeneous collection of images, where each image can have a different mode, height, and width. This is much more flexible, but will result in a less compact representation and may be make some operations less efficient.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mode | str | ImageMode | None | The mode of the image. By default, this is inferred from the underlying data. If height and width are specified, the mode must also be specified. | None |
height | int | None | The height of the image. By default, this is inferred from the underlying data. Must be specified if the width is specified. | None |
width | int | None | The width of the image. By default, this is inferred from the underlying data. Must be specified if the width is specified. | None |
Source code in daft/datatype.py
627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 | |
infer_from_object #
infer_from_object(obj: Any) -> DataType
Infer Daft DataType from a Python object.
Source code in daft/datatype.py
486 487 488 489 490 491 492 | |
infer_from_type #
infer_from_type(t: type | GenericAlias | UnionType) -> DataType
Infer Daft DataType from a Python type.
Source code in daft/datatype.py
177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 | |
is_binary #
is_binary() -> bool
Check if this is a binary type.
Examples:
1 2 3 | |
Source code in daft/datatype.py
1077 1078 1079 1080 1081 1082 1083 1084 1085 | |
is_boolean #
is_boolean() -> bool
Check if this is a boolean type.
Examples:
1 2 3 | |
Source code in daft/datatype.py
903 904 905 906 907 908 909 910 911 | |
is_date #
is_date() -> bool
Check if this is a date type.
Examples:
1 2 3 | |
Source code in daft/datatype.py
1037 1038 1039 1040 1041 1042 1043 1044 1045 | |
is_decimal128 #
is_decimal128() -> bool
Check if this is a decimal128 type.
Examples:
1 2 3 | |
Source code in daft/datatype.py
1017 1018 1019 1020 1021 1022 1023 1024 1025 | |
is_duration #
is_duration() -> bool
Check if this is a duration type.
Examples:
1 2 3 | |
Source code in daft/datatype.py
1057 1058 1059 1060 1061 1062 1063 1064 1065 | |
is_embedding #
is_embedding() -> bool
Check if this is an embedding type.
Examples:
1 2 3 | |
Source code in daft/datatype.py
1197 1198 1199 1200 1201 1202 1203 1204 1205 | |
is_extension #
is_extension() -> bool
Check if this is an extension type.
Examples:
1 2 3 | |
Source code in daft/datatype.py
1167 1168 1169 1170 1171 1172 1173 1174 1175 | |
is_file #
is_file() -> bool
Check if this is a file type.
Examples:
1 2 3 | |
Source code in daft/datatype.py
1297 1298 1299 1300 1301 1302 1303 1304 1305 | |
is_fixed_shape_image #
is_fixed_shape_image() -> bool
Check if this is a fixed shape image type.
Examples:
1 2 3 | |
Source code in daft/datatype.py
1187 1188 1189 1190 1191 1192 1193 1194 1195 | |
is_fixed_shape_sparse_tensor #
is_fixed_shape_sparse_tensor() -> bool
Check if this is a fixed shape sparse tensor type.
Examples:
1 2 3 | |
Source code in daft/datatype.py
1237 1238 1239 1240 1241 1242 1243 1244 1245 | |
is_fixed_shape_tensor #
is_fixed_shape_tensor() -> bool
Check if this is a fixed shape tensor type.
Examples:
1 2 3 | |
Source code in daft/datatype.py
1217 1218 1219 1220 1221 1222 1223 1224 1225 | |
is_fixed_size_binary #
is_fixed_size_binary() -> bool
Check if this is a fixed size binary type.
Examples:
1 2 3 | |
Source code in daft/datatype.py
1087 1088 1089 1090 1091 1092 1093 1094 1095 | |
is_fixed_size_list #
is_fixed_size_list() -> bool
Check if this is a fixed size list type.
Examples:
1 2 3 | |
Source code in daft/datatype.py
1127 1128 1129 1130 1131 1132 1133 1134 1135 | |
is_float16 #
is_float16() -> bool
Check if this is a 16-bit float type.
Source code in daft/datatype.py
993 994 995 | |
is_float32 #
is_float32() -> bool
Check if this is a 32-bit float type.
Examples:
1 2 3 | |
Source code in daft/datatype.py
997 998 999 1000 1001 1002 1003 1004 1005 | |
is_float64 #
is_float64() -> bool
Check if this is a 64-bit float type.
Examples:
1 2 3 | |
Source code in daft/datatype.py
1007 1008 1009 1010 1011 1012 1013 1014 1015 | |
is_image #
is_image() -> bool
Check if this is an image type.
Examples:
1 2 3 | |
Source code in daft/datatype.py
1177 1178 1179 1180 1181 1182 1183 1184 1185 | |
is_int16 #
is_int16() -> bool
Check if this is a 16-bit integer type.
Examples:
1 2 3 | |
Source code in daft/datatype.py
923 924 925 926 927 928 929 930 931 | |
is_int32 #
is_int32() -> bool
Check if this is a 32-bit integer type.
Examples:
1 2 3 | |
Source code in daft/datatype.py
933 934 935 936 937 938 939 940 941 | |
is_int64 #
is_int64() -> bool
Check if this is a 64-bit integer type.
Examples:
1 2 3 | |
Source code in daft/datatype.py
943 944 945 946 947 948 949 950 951 | |
is_int8 #
is_int8() -> bool
Check if this is an 8-bit integer type.
Examples:
1 2 3 | |
Source code in daft/datatype.py
913 914 915 916 917 918 919 920 921 | |
is_integer #
is_integer() -> bool
Check if this is an integer type.
Examples:
1 2 3 | |
Source code in daft/datatype.py
1267 1268 1269 1270 1271 1272 1273 1274 1275 | |
is_interval #
is_interval() -> bool
Check if this is an interval type.
Examples:
1 2 3 | |
Source code in daft/datatype.py
1067 1068 1069 1070 1071 1072 1073 1074 1075 | |
is_list #
is_list() -> bool
Check if this is a list type.
Examples:
1 2 3 | |
Source code in daft/datatype.py
1117 1118 1119 1120 1121 1122 1123 1124 1125 | |
is_logical #
is_logical() -> bool
Check if this is a logical type.
Examples:
1 2 3 | |
Source code in daft/datatype.py
1277 1278 1279 1280 1281 1282 1283 1284 1285 | |
is_map #
is_map() -> bool
Check if this is a map type.
Examples:
1 2 3 | |
Source code in daft/datatype.py
1147 1148 1149 1150 1151 1152 1153 1154 1155 | |
is_null #
is_null() -> bool
Check if this is a null type.
Examples:
1 2 3 | |
True Source code in daft/datatype.py
892 893 894 895 896 897 898 899 900 901 | |
is_numeric #
is_numeric() -> bool
Check if this is a numeric type.
Examples:
1 2 3 | |
Source code in daft/datatype.py
1257 1258 1259 1260 1261 1262 1263 1264 1265 | |
is_python #
is_python() -> bool
Check if this is a python object type.
Examples:
1 2 3 | |
Source code in daft/datatype.py
1247 1248 1249 1250 1251 1252 1253 1254 1255 | |
is_sparse_tensor #
is_sparse_tensor() -> bool
Check if this is a sparse tensor type.
Examples:
1 2 3 | |
Source code in daft/datatype.py
1227 1228 1229 1230 1231 1232 1233 1234 1235 | |
is_string #
is_string() -> bool
Check if this is a string type.
Examples:
1 2 3 | |
Source code in daft/datatype.py
1107 1108 1109 1110 1111 1112 1113 1114 1115 | |
is_struct #
is_struct() -> bool
Check if this is a struct type.
Examples:
1 2 3 | |
Source code in daft/datatype.py
1137 1138 1139 1140 1141 1142 1143 1144 1145 | |
is_temporal #
is_temporal() -> bool
Check if this is a temporal type.
Examples:
1 2 3 | |
Source code in daft/datatype.py
1287 1288 1289 1290 1291 1292 1293 1294 1295 | |
is_tensor #
is_tensor() -> bool
Check if this is a tensor type.
Examples:
1 2 3 | |
Source code in daft/datatype.py
1207 1208 1209 1210 1211 1212 1213 1214 1215 | |
is_time #
is_time() -> bool
Check if this is a time type.
Examples:
1 2 3 | |
Source code in daft/datatype.py
1047 1048 1049 1050 1051 1052 1053 1054 1055 | |
is_timestamp #
is_timestamp() -> bool
Check if this is a timestamp type.
Examples:
1 2 3 | |
Source code in daft/datatype.py
1027 1028 1029 1030 1031 1032 1033 1034 1035 | |
is_uint16 #
is_uint16() -> bool
Check if this is an unsigned 16-bit integer type.
Examples:
1 2 3 | |
Source code in daft/datatype.py
963 964 965 966 967 968 969 970 971 | |
is_uint32 #
is_uint32() -> bool
Check if this is an unsigned 32-bit integer type.
Examples:
1 2 3 | |
Source code in daft/datatype.py
973 974 975 976 977 978 979 980 981 | |
is_uint64 #
is_uint64() -> bool
Check if this is an unsigned 64-bit integer type.
Examples:
1 2 3 | |
Source code in daft/datatype.py
983 984 985 986 987 988 989 990 991 | |
is_uint8 #
is_uint8() -> bool
Check if this is an unsigned 8-bit integer type.
Examples:
1 2 3 | |
Source code in daft/datatype.py
953 954 955 956 957 958 959 960 961 | |
is_union #
is_union() -> bool
Check if this is a union type.
Examples:
1 2 3 | |
Source code in daft/datatype.py
1157 1158 1159 1160 1161 1162 1163 1164 1165 | |
is_uuid #
is_uuid() -> bool
Check if this is a UUID type.
Examples:
1 2 3 | |
Source code in daft/datatype.py
1097 1098 1099 1100 1101 1102 1103 1104 1105 | |
list #
Create a List DataType: Variable-length list, where each element in the list has type dtype.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dtype | DataType | DataType of each element in the list | required |
Source code in daft/datatype.py
562 563 564 565 566 567 568 569 570 | |
map #
Create a Map DataType: A map is a nested type of key-value pairs that is implemented as a list of structs with two fields, key and value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key_type | DataType | DataType of the keys in the map | required |
value_type | DataType | DataType of the values in the map | required |
Source code in daft/datatype.py
585 586 587 588 589 590 591 592 593 594 | |
sparse_tensor #
sparse_tensor(dtype: DataType, shape: tuple[int, ...] | None = None, use_offset_indices: bool = False) -> DataType
Create a SparseTensor DataType: SparseTensor arrays implemented as 'COO Sparse Tensor' representation of n-dimensional arrays of data of the provided dtype as elements, each of the provided shape.
If a shape is given, each ndarray in the column will have this shape.
If shape is not given, the ndarrays in the column can have different shapes. This is much more flexible, but will result in a less compact representation and may be make some operations less efficient.
The use_offset_indices parameter determines how the indices of the SparseTensor are stored: - False (default): Indices represent the actual positions of nonzero values. - True: Indices represent the offsets between consecutive nonzero values. This can improve compression efficiency, especially when nonzero values are clustered together, as offsets between them are often zero, making them easier to compress.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dtype | DataType | The type of the data contained within the tensor elements. | required |
shape | tuple[int, ...] | None | The shape of each SparseTensor in the column. This is | None |
use_offset_indices | bool | Determines how indices are represented. Defaults to | False |
Source code in daft/datatype.py
693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 | |
struct #
Create a Struct DataType: a nested type which has names mapped to child types.
Examples:
1 | |
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fields | dict[str, DataType] | Nested fields of the Struct | required |
Source code in daft/datatype.py
596 597 598 599 600 601 602 603 604 605 606 607 | |
tensor #
Create a tensor DataType: tensor arrays contain n-dimensional arrays of data of the provided dtype as elements, each of the provided shape.
If a shape is given, each ndarray in the column will have this shape.
If shape is not given, the ndarrays in the column can have different shapes. This is much more flexible, but will result in a less compact representation and may be make some operations less efficient.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dtype | DataType | The type of the data contained within the tensor elements. | required |
shape | tuple[int, ...] | None | The shape of each tensor in the column. This is | None |
Source code in daft/datatype.py
669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 | |
time #
time(timeunit: TimeUnit | str) -> DataType
Time DataType. Supported timeunits are "us", "ns".
Source code in daft/datatype.py
538 539 540 541 542 543 544 | |
timestamp #
timestamp(timeunit: TimeUnit | str, timezone: str | None = None) -> DataType
Timestamp DataType.
Source code in daft/datatype.py
546 547 548 549 550 551 552 | |
to_arrow_dtype #
to_arrow_dtype() -> DataType
Source code in daft/datatype.py
855 856 857 | |
union #
union(fields: dict[str, DataType], type_ids: list[int], mode: str | UnionMode = 'sparse') -> DataType
Create a Union DataType: a union of named fields, each with its own type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fields | dict[str, DataType] | Mapping of field names to their DataTypes | required |
type_ids | list[int] | Type IDs (one per field) used to identify which variant is stored | required |
mode | str | UnionMode | Union mode, either | 'sparse' |
Examples:
1 2 3 4 5 6 | |
Source code in daft/datatype.py
865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 | |