@@ -96,9 +96,6 @@ from pandas._libs.missing cimport (
9696 is_null_datetime64,
9797 is_null_timedelta64,
9898)
99-
100- from pandas._libs.tslibs.timestamps import Timestamp
101-
10299from pandas._libs.tslibs.conversion cimport convert_to_tsobject
103100from pandas._libs.tslibs.nattype cimport (
104101 NPY_NAT,
@@ -1303,7 +1300,6 @@ cdef class Seen:
13031300 bint object_ # seen_object
13041301 bint complex_ # seen_complex
13051302 bint datetime_ # seen_datetime
1306- bint date_ # seen_date
13071303 bint coerce_numeric # coerce data to numeric
13081304 bint timedelta_ # seen_timedelta
13091305 bint datetimetz_ # seen_datetimetz
@@ -1332,7 +1328,6 @@ cdef class Seen:
13321328 self .object_ = False
13331329 self .complex_ = False
13341330 self .datetime_ = False
1335- self .date_ = False
13361331 self .timedelta_ = False
13371332 self .datetimetz_ = False
13381333 self .period_ = False
@@ -2675,16 +2670,6 @@ def maybe_convert_objects(ndarray[object] objects,
26752670 else :
26762671 seen.object_ = True
26772672 break
2678- elif (
2679- PyDate_Check(val)
2680- or (pa is not None and isinstance (val, (pa.Date32Scalar, pa.Date64Scalar)))
2681- ):
2682- if convert_non_numeric:
2683- seen.date_ = True
2684- break
2685- else :
2686- seen.object_ = True
2687- break
26882673 elif is_period_object(val):
26892674 if convert_non_numeric:
26902675 seen.period_ = True
@@ -2739,35 +2724,18 @@ def maybe_convert_objects(ndarray[object] objects,
27392724
27402725 # we try to coerce datetime w/tz but must all have the same tz
27412726 if seen.datetimetz_:
2742- if storage == " pyarrow " :
2743- from pandas.core.dtypes.dtypes import ArrowDtype
2727+ if is_datetime_with_singletz_array(objects) :
2728+ from pandas import DatetimeIndex
27442729
2745- datetime64_array = None
2746- if isinstance (val, datetime):
2747- objects[mask] = None
2748- datetime64_array = objects.astype(Timestamp)
2730+ try :
2731+ dti = DatetimeIndex(objects)
2732+ except OutOfBoundsDatetime:
2733+ # e.g. test_to_datetime_cache_coerce_50_lines_outofbounds
2734+ pass
27492735 else :
2750- objects[mask] = np.datetime64(" NaT" )
2751- datetime64_array = objects.astype(val.dtype)
2752- pa_array = pa.array(datetime64_array).cast(
2753- pa.timestamp(val.resolution.unit, val.tzinfo)
2754- )
2755- dtype = ArrowDtype(pa_array.type)
2756- return dtype.construct_array_type()._from_sequence(pa_array, dtype = dtype)
2757-
2758- else :
2759- if is_datetime_with_singletz_array(objects):
2760- from pandas import DatetimeIndex
2761-
2762- try :
2763- dti = DatetimeIndex(objects)
2764- except OutOfBoundsDatetime:
2765- # e.g. test_to_datetime_cache_coerce_50_lines_outofbounds
2766- pass
2767- else :
2768- # unbox to DatetimeArray
2769- return dti._data
2770- seen.object_ = True
2736+ # unbox to DatetimeArray
2737+ return dti._data
2738+ seen.object_ = True
27712739
27722740 elif seen.datetime_:
27732741 if is_datetime_or_datetime64_array(objects):
0 commit comments