File tree Expand file tree Collapse file tree 3 files changed +12
-4
lines changed Expand file tree Collapse file tree 3 files changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -115,19 +115,27 @@ def time_maybe_convert_objects(self):
115115class ToDatetimeFromIntsFloats :
116116 def setup (self ):
117117 self .ts_sec = Series (range (1521080307 , 1521685107 ), dtype = "int64" )
118+ self .ts_sec_uint = Series (range (1521080307 , 1521685107 ), dtype = "uint64" )
118119 self .ts_sec_float = self .ts_sec .astype ("float64" )
119120
120121 self .ts_nanosec = 1_000_000 * self .ts_sec
122+ self .ts_nanosec_uint = 1_000_000 * self .ts_sec_uint
121123 self .ts_nanosec_float = self .ts_nanosec .astype ("float64" )
122124
123- # speed of int64 and float64 paths should be comparable
125+ # speed of int64, uint64 and float64 paths should be comparable
124126
125127 def time_nanosec_int64 (self ):
126128 to_datetime (self .ts_nanosec , unit = "ns" )
127129
130+ def time_nanosec_uint64 (self ):
131+ to_datetime (self .ts_nanosec_uint , unit = "ns" )
132+
128133 def time_nanosec_float64 (self ):
129134 to_datetime (self .ts_nanosec_float , unit = "ns" )
130135
136+ def time_sec_uint64 (self ):
137+ to_datetime (self .ts_sec_uint , unit = "s" )
138+
131139 def time_sec_int64 (self ):
132140 to_datetime (self .ts_sec , unit = "s" )
133141
Original file line number Diff line number Diff line change @@ -245,7 +245,7 @@ Performance improvements
245245- Performance improvement in :meth: `DataFrame.corr ` for ``method=pearson `` on data without missing values (:issue: `40956 `)
246246- Performance improvement in some :meth: `GroupBy.apply ` operations (:issue: `42992 `)
247247- Performance improvement in :func: `read_stata ` (:issue: `43059 `)
248- -
248+ - Performance improvement in :meth: ` to_datetime ` with `` uint `` dtypes ( :issue: ` 42606 `)
249249
250250.. ---------------------------------------------------------------------------
251251
Original file line number Diff line number Diff line change @@ -248,7 +248,7 @@ def array_with_unit_to_datetime(
248248 # if we have nulls that are not type-compat
249249 # then need to iterate
250250
251- if values.dtype.kind == " i" or values.dtype.kind == " f" :
251+ if values.dtype.kind in [ " i" , " f" , " u " ] :
252252 iresult = values.astype(" i8" , copy = False )
253253 # fill missing values by comparing to NPY_NAT
254254 mask = iresult == NPY_NAT
@@ -263,7 +263,7 @@ def array_with_unit_to_datetime(
263263 ):
264264 raise OutOfBoundsDatetime(f" cannot convert input with unit '{unit}'" )
265265
266- if values.dtype.kind == " i" :
266+ if values.dtype.kind in [ " i" , " u " ] :
267267 result = (iresult * m).astype(" M8[ns]" )
268268
269269 elif values.dtype.kind == " f" :
You can’t perform that action at this time.
0 commit comments