@@ -2242,44 +2242,26 @@ class DatetimeTZBlock(ExtensionBlock, DatetimeBlock):
2242
2242
is_datetimetz = True
2243
2243
is_extension = True
2244
2244
2245
- def __init__ (self , values , placement , ndim = 2 , dtype = None ):
2246
- # XXX: This will end up calling _maybe_coerce_values twice
2247
- # when dtype is not None. It's relatively cheap (just an isinstance)
2248
- # but it'd nice to avoid.
2249
- #
2250
- # If we can remove dtype from __init__, and push that conversion
2251
- # push onto the callers, then we can remove this entire __init__
2252
- # and just use DatetimeBlock's.
2253
- if dtype is not None :
2254
- values = self ._maybe_coerce_values (values , dtype = dtype )
2255
- super (DatetimeTZBlock , self ).__init__ (values , placement = placement ,
2256
- ndim = ndim )
2257
-
2258
2245
@property
2259
2246
def _holder (self ):
2260
2247
return DatetimeArray
2261
2248
2262
- def _maybe_coerce_values (self , values , dtype = None ):
2249
+ def _maybe_coerce_values (self , values ):
2263
2250
"""Input validation for values passed to __init__. Ensure that
2264
2251
we have datetime64TZ, coercing if necessary.
2265
2252
2266
2253
Parametetrs
2267
2254
-----------
2268
2255
values : array-like
2269
2256
Must be convertible to datetime64
2270
- dtype : string or DatetimeTZDtype, optional
2271
- Does a shallow copy to this tz
2272
2257
2273
2258
Returns
2274
2259
-------
2275
- values : ndarray[datetime64ns]
2260
+ values : DatetimeArray
2276
2261
"""
2277
2262
if not isinstance (values , self ._holder ):
2278
2263
values = self ._holder (values )
2279
2264
2280
- if dtype is not None :
2281
- values = type (values )(values , dtype = dtype )
2282
-
2283
2265
if values .tz is None :
2284
2266
raise ValueError ("cannot create a DatetimeTZBlock without a tz" )
2285
2267
@@ -3094,8 +3076,9 @@ def make_block(values, placement, klass=None, ndim=None, dtype=None,
3094
3076
klass = get_block_type (values , dtype )
3095
3077
3096
3078
elif klass is DatetimeTZBlock and not is_datetime64tz_dtype (values ):
3097
- return klass (values , ndim = ndim ,
3098
- placement = placement , dtype = dtype )
3079
+ # TODO: This is no longer hit internally; does it need to be retained
3080
+ # for e.g. pyarrow?
3081
+ values = DatetimeArray (values , dtype )
3099
3082
3100
3083
return klass (values , ndim = ndim , placement = placement )
3101
3084
0 commit comments