Skip to content

Commit aa6fe7d

Browse files
flexatonehonno
andauthored
Clarify dtype type in ColumnBuffers elements (#87)
Co-authored-by: Matthew Barber <quitesimplymatt@gmail.com>
1 parent 2b37b1d commit aa6fe7d

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

protocol/dataframe_protocol.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ class DtypeKind(enum.IntEnum):
5858
CATEGORICAL = 23
5959

6060

61+
Dtype = Tuple[DtypeKind, int, str, str] # see Column.dtype
62+
63+
6164
class ColumnNullType(enum.IntEnum):
6265
"""
6366
Integer enum for null type representation.
@@ -86,18 +89,18 @@ class ColumnNullType(enum.IntEnum):
8689
class ColumnBuffers(TypedDict):
8790
# first element is a buffer containing the column data;
8891
# second element is the data buffer's associated dtype
89-
data: Tuple["Buffer", Any]
92+
data: Tuple["Buffer", Dtype]
9093

9194
# first element is a buffer containing mask values indicating missing data;
9295
# second element is the mask value buffer's associated dtype.
9396
# None if the null representation is not a bit or byte mask
94-
validity: Optional[Tuple["Buffer", Any]]
97+
validity: Optional[Tuple["Buffer", Dtype]]
9598

9699
# first element is a buffer containing the offset values for
97100
# variable-size binary data (e.g., variable-length strings);
98101
# second element is the offsets buffer's associated dtype.
99102
# None if the data buffer does not have an associated offsets buffer
100-
offsets: Optional[Tuple["Buffer", Any]]
103+
offsets: Optional[Tuple["Buffer", Dtype]]
101104

102105

103106
class CategoricalDescription(TypedDict):
@@ -237,7 +240,7 @@ def offset(self) -> int:
237240

238241
@property
239242
@abstractmethod
240-
def dtype(self) -> Tuple[DtypeKind, int, str, str]:
243+
def dtype(self) -> Dtype:
241244
"""
242245
Dtype description as a tuple ``(kind, bit-width, format string, endianness)``.
243246

0 commit comments

Comments
 (0)