@@ -2242,44 +2242,26 @@ class DatetimeTZBlock(ExtensionBlock, DatetimeBlock):
22422242 is_datetimetz = True
22432243 is_extension = True
22442244
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-
22582245 @property
22592246 def _holder (self ):
22602247 return DatetimeArray
22612248
2262- def _maybe_coerce_values (self , values , dtype = None ):
2249+ def _maybe_coerce_values (self , values ):
22632250 """Input validation for values passed to __init__. Ensure that
22642251 we have datetime64TZ, coercing if necessary.
22652252
22662253 Parametetrs
22672254 -----------
22682255 values : array-like
22692256 Must be convertible to datetime64
2270- dtype : string or DatetimeTZDtype, optional
2271- Does a shallow copy to this tz
22722257
22732258 Returns
22742259 -------
2275- values : ndarray[datetime64ns]
2260+ values : DatetimeArray
22762261 """
22772262 if not isinstance (values , self ._holder ):
22782263 values = self ._holder (values )
22792264
2280- if dtype is not None :
2281- values = type (values )(values , dtype = dtype )
2282-
22832265 if values .tz is None :
22842266 raise ValueError ("cannot create a DatetimeTZBlock without a tz" )
22852267
@@ -3094,8 +3076,9 @@ def make_block(values, placement, klass=None, ndim=None, dtype=None,
30943076 klass = get_block_type (values , dtype )
30953077
30963078 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 )
30993082
31003083 return klass (values , ndim = ndim , placement = placement )
31013084
0 commit comments