File tree 2 files changed +14
-3
lines changed
2 files changed +14
-3
lines changed Original file line number Diff line number Diff line change 19
19
)
20
20
21
21
from pandas .core .arrays import DatetimeArray
22
+ from pandas .core .construction import extract_array
22
23
from pandas .core .internals .blocks import (
23
24
Block ,
24
25
DatetimeTZBlock ,
@@ -49,21 +50,21 @@ def make_block(
49
50
50
51
values , dtype = extract_pandas_array (values , dtype , ndim )
51
52
52
- needs_reshape = False
53
53
if klass is None :
54
54
dtype = dtype or values .dtype
55
55
klass = get_block_type (values , dtype )
56
56
57
57
elif klass is DatetimeTZBlock and not is_datetime64tz_dtype (values .dtype ):
58
58
# pyarrow calls get here
59
59
values = DatetimeArray ._simple_new (values , dtype = dtype )
60
- needs_reshape = True
61
60
62
61
if not isinstance (placement , BlockPlacement ):
63
62
placement = BlockPlacement (placement )
64
63
65
64
ndim = maybe_infer_ndim (values , placement , ndim )
66
- if needs_reshape :
65
+ if is_datetime64tz_dtype (values .dtype ):
66
+ # GH#41168 ensure we can pass 1D dt64tz values
67
+ values = extract_array (values , extract_numpy = True )
67
68
values = ensure_block_shape (values , ndim )
68
69
69
70
check_ndim (values , placement , ndim )
Original file line number Diff line number Diff line change 3
3
in core.internals
4
4
"""
5
5
6
+ import pandas as pd
6
7
from pandas .core import internals
7
8
from pandas .core .internals import api
8
9
@@ -44,3 +45,12 @@ def test_namespace():
44
45
45
46
result = [x for x in dir (internals ) if not x .startswith ("__" )]
46
47
assert set (result ) == set (expected + modules )
48
+
49
+
50
+ def test_make_block_2d_with_dti ():
51
+ # GH#41168
52
+ dti = pd .date_range ("2012" , periods = 3 , tz = "UTC" )
53
+ blk = api .make_block (dti , placement = [0 ])
54
+
55
+ assert blk .shape == (1 , 3 )
56
+ assert blk .values .shape == (1 , 3 )
You can’t perform that action at this time.
0 commit comments