@@ -953,6 +953,7 @@ cdef class Seen:
953
953
954
954
cdef:
955
955
bint int_ # seen_int
956
+ bint nat_ # seen nat
956
957
bint bool_ # seen_bool
957
958
bint null_ # seen_null
958
959
bint uint_ # seen_uint (unsigned integer)
@@ -976,6 +977,7 @@ cdef class Seen:
976
977
initial methods to convert to numeric fail.
977
978
"""
978
979
self .int_ = 0
980
+ self .nat_ = 0
979
981
self .bool_ = 0
980
982
self .null_ = 0
981
983
self .uint_ = 0
@@ -1055,11 +1057,13 @@ cdef class Seen:
1055
1057
1056
1058
@property
1057
1059
def is_bool (self ):
1058
- return not (self .datetime_ or self .numeric_ or self .timedelta_)
1060
+ return not (self .datetime_ or self .numeric_ or self .timedelta_
1061
+ or self .nat_)
1059
1062
1060
1063
@property
1061
1064
def is_float_or_complex (self ):
1062
- return not (self .bool_ or self .datetime_ or self .timedelta_)
1065
+ return not (self .bool_ or self .datetime_ or self .timedelta_
1066
+ or self .nat_)
1063
1067
1064
1068
1065
1069
cdef _try_infer_map(v):
@@ -1958,12 +1962,11 @@ def maybe_convert_objects(ndarray[object] objects, bint try_float=0,
1958
1962
seen.null_ = 1
1959
1963
floats[i] = complexes[i] = fnan
1960
1964
elif val is NaT:
1965
+ seen.nat_ = 1
1961
1966
if convert_datetime:
1962
1967
idatetimes[i] = NPY_NAT
1963
- seen.datetime_ = 1
1964
1968
if convert_timedelta:
1965
1969
itimedeltas[i] = NPY_NAT
1966
- seen.timedelta_ = 1
1967
1970
if not (convert_datetime or convert_timedelta):
1968
1971
seen.object_ = 1
1969
1972
break
@@ -2057,11 +2060,20 @@ def maybe_convert_objects(ndarray[object] objects, bint try_float=0,
2057
2060
else :
2058
2061
if not seen.bool_:
2059
2062
if seen.datetime_:
2060
- if not seen.numeric_:
2063
+ if not seen.numeric_ and not seen.timedelta_ :
2061
2064
return datetimes
2062
2065
elif seen.timedelta_:
2063
2066
if not seen.numeric_:
2064
2067
return timedeltas
2068
+ elif seen.nat_:
2069
+ if not seen.numeric_:
2070
+ if convert_datetime and convert_timedelta:
2071
+ # TODO: array full of NaT ambiguity resolve here needed
2072
+ pass
2073
+ elif convert_datetime:
2074
+ return datetimes
2075
+ elif convert_timedelta:
2076
+ return timedeltas
2065
2077
else :
2066
2078
if seen.complex_:
2067
2079
return complexes
@@ -2088,11 +2100,20 @@ def maybe_convert_objects(ndarray[object] objects, bint try_float=0,
2088
2100
else :
2089
2101
if not seen.bool_:
2090
2102
if seen.datetime_:
2091
- if not seen.numeric_:
2103
+ if not seen.numeric_ and not seen.timedelta_ :
2092
2104
return datetimes
2093
2105
elif seen.timedelta_:
2094
2106
if not seen.numeric_:
2095
2107
return timedeltas
2108
+ elif seen.nat_:
2109
+ if not seen.numeric_:
2110
+ if convert_datetime and convert_timedelta:
2111
+ # TODO: array full of NaT ambiguity resolve here needed
2112
+ pass
2113
+ elif convert_datetime:
2114
+ return datetimes
2115
+ elif convert_timedelta:
2116
+ return timedeltas
2096
2117
else :
2097
2118
if seen.complex_:
2098
2119
if not seen.int_:
0 commit comments