File tree Expand file tree Collapse file tree 2 files changed +35
-32
lines changed
pandas/tests/extension/arrow Expand file tree Collapse file tree 2 files changed +35
-32
lines changed Original file line number Diff line number Diff line change 77current implementation is not efficient.
88"""
99import copy
10- import datetime
1110import itertools
1211import operator
1312from typing import Type
@@ -68,26 +67,6 @@ def construct_array_type(cls) -> Type["ArrowStringArray"]:
6867 return ArrowStringArray
6968
7069
71- @register_extension_dtype
72- class ArrowTimestampUSDtype (ExtensionDtype ):
73-
74- type = datetime .datetime
75- kind = "M"
76- name = "arrow_timestamp_us"
77- na_value = pa .NULL
78-
79- @classmethod
80- def construct_array_type (cls ) -> Type ["ArrowTimestampUSArray" ]:
81- """
82- Return the array type associated with this dtype.
83-
84- Returns
85- -------
86- type
87- """
88- return ArrowTimestampUSArray
89-
90-
9170class ArrowExtensionArray (ExtensionArray ):
9271 @classmethod
9372 def from_scalars (cls , values ):
@@ -222,13 +201,3 @@ def __init__(self, values):
222201 assert values .type == pa .string ()
223202 self ._data = values
224203 self ._dtype = ArrowStringDtype ()
225-
226-
227- class ArrowTimestampUSArray (ArrowExtensionArray ):
228- def __init__ (self , values ):
229- if not isinstance (values , pa .ChunkedArray ):
230- raise ValueError
231-
232- assert values .type == pa .timestamp ("us" )
233- self ._data = values
234- self ._dtype = ArrowTimestampUSDtype ()
Original file line number Diff line number Diff line change 11import datetime
2+ from typing import Type
23
34import pytest
45
56import pandas as pd
7+ from pandas .api .extensions import ExtensionDtype , register_extension_dtype
68
79pytest .importorskip ("pyarrow" , minversion = "0.13.0" )
810
9- from .arrays import ArrowTimestampUSArray # isort:skip
11+ import pyarrow as pa # isort:skip
12+
13+ from .arrays import ArrowExtensionArray # isort:skip
14+
15+
16+ @register_extension_dtype
17+ class ArrowTimestampUSDtype (ExtensionDtype ):
18+
19+ type = datetime .datetime
20+ kind = "M"
21+ name = "arrow_timestamp_us"
22+ na_value = pa .NULL
23+
24+ @classmethod
25+ def construct_array_type (cls ) -> Type ["ArrowTimestampUSArray" ]:
26+ """
27+ Return the array type associated with this dtype.
28+
29+ Returns
30+ -------
31+ type
32+ """
33+ return ArrowTimestampUSArray
34+
35+
36+ class ArrowTimestampUSArray (ArrowExtensionArray ):
37+ def __init__ (self , values ):
38+ if not isinstance (values , pa .ChunkedArray ):
39+ raise ValueError
40+
41+ assert values .type == pa .timestamp ("us" )
42+ self ._data = values
43+ self ._dtype = ArrowTimestampUSDtype ()
1044
1145
1246@pytest .mark .xfail (
You can’t perform that action at this time.
0 commit comments