File tree 3 files changed +17
-2
lines changed
3 files changed +17
-2
lines changed Original file line number Diff line number Diff line change 5
5
import numpy as np
6
6
7
7
from pandas ._libs .lib import infer_dtype
8
+ from pandas ._libs .tslibs import iNaT
8
9
from pandas .util ._decorators import cache_readonly
9
10
10
11
import pandas as pd
38
39
39
40
_NULL_DESCRIPTION = {
40
41
DtypeKind .FLOAT : (ColumnNullType .USE_NAN , None ),
41
- DtypeKind .DATETIME : (ColumnNullType .USE_NAN , None ),
42
+ DtypeKind .DATETIME : (ColumnNullType .USE_SENTINEL , iNaT ),
42
43
DtypeKind .INT : (ColumnNullType .NON_NULLABLE , None ),
43
44
DtypeKind .UINT : (ColumnNullType .NON_NULLABLE , None ),
44
45
DtypeKind .BOOL : (ColumnNullType .NON_NULLABLE , None ),
Original file line number Diff line number Diff line change @@ -70,7 +70,7 @@ class ColumnNullType(enum.IntEnum):
70
70
NON_NULLABLE : int
71
71
Non-nullable column.
72
72
USE_NAN : int
73
- Use explicit float NaN/NaT value.
73
+ Use explicit float NaN value.
74
74
USE_SENTINEL : int
75
75
Sentinel value besides NaN/NaT.
76
76
USE_BITMASK : int
Original file line number Diff line number Diff line change 4
4
import numpy as np
5
5
import pytest
6
6
7
+ from pandas ._libs .tslibs import iNaT
8
+
7
9
import pandas as pd
8
10
import pandas ._testing as tm
9
11
from pandas .core .interchange .dataframe_protocol import (
@@ -176,3 +178,15 @@ def test_nonstring_object():
176
178
col = df .__dataframe__ ().get_column_by_name ("A" )
177
179
with pytest .raises (NotImplementedError , match = "not supported yet" ):
178
180
col .dtype
181
+
182
+
183
+ def test_datetime ():
184
+ df = pd .DataFrame ({"A" : [pd .Timestamp ("2022-01-01" ), pd .NaT ]})
185
+ col = df .__dataframe__ ().get_column_by_name ("A" )
186
+
187
+ assert col .size == 2
188
+ assert col .null_count == 1
189
+ assert col .dtype [0 ] == DtypeKind .DATETIME
190
+ assert col .describe_null == (ColumnNullType .USE_SENTINEL , iNaT )
191
+
192
+ tm .assert_frame_equal (df , from_dataframe (df .__dataframe__ ()))
You can’t perform that action at this time.
0 commit comments