File tree 2 files changed +35
-32
lines changed
pandas/tests/extension/arrow
2 files changed +35
-32
lines changed Original file line number Diff line number Diff line change 7
7
current implementation is not efficient.
8
8
"""
9
9
import copy
10
- import datetime
11
10
import itertools
12
11
import operator
13
12
from typing import Type
@@ -68,26 +67,6 @@ def construct_array_type(cls) -> Type["ArrowStringArray"]:
68
67
return ArrowStringArray
69
68
70
69
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
-
91
70
class ArrowExtensionArray (ExtensionArray ):
92
71
@classmethod
93
72
def from_scalars (cls , values ):
@@ -222,13 +201,3 @@ def __init__(self, values):
222
201
assert values .type == pa .string ()
223
202
self ._data = values
224
203
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 1
1
import datetime
2
+ from typing import Type
2
3
3
4
import pytest
4
5
5
6
import pandas as pd
7
+ from pandas .api .extensions import ExtensionDtype , register_extension_dtype
6
8
7
9
pytest .importorskip ("pyarrow" , minversion = "0.13.0" )
8
10
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 ()
10
44
11
45
12
46
@pytest .mark .xfail (
You can’t perform that action at this time.
0 commit comments