File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -2660,6 +2660,7 @@ def maybe_convert_objects(ndarray[object] objects,
2660
2660
2661
2661
elif seen.time_:
2662
2662
if is_time_array(objects):
2663
+ # FIXME: need to ensure this is not timetz
2663
2664
opt = get_option(" future.infer_time" )
2664
2665
if opt is True :
2665
2666
import pyarrow as pa
Original file line number Diff line number Diff line change @@ -843,6 +843,29 @@ def infer_dtype_from_scalar(val) -> tuple[DtypeObj, Any]:
843
843
pa_dtype = pa .time64 ("us" )
844
844
dtype = ArrowDtype (pa_dtype )
845
845
846
+ elif isinstance (val , dt .time ):
847
+ if val .tzinfo is None :
848
+ # pyarrow doesn't have a dtype for timetz.
849
+ opt = get_option ("future.infer_time" )
850
+ if opt is None :
851
+ warnings .warn (
852
+ "Pandas type inference with a `datetime.time` "
853
+ "object is deprecated. In a future version, this will give "
854
+ "time32[pyarrow] dtype, which will require pyarrow to be "
855
+ "installed. To opt in to the new behavior immediately set "
856
+ "`pd.set_option('future.infer_time', True)`. To keep the "
857
+ "old behavior pass `dtype=object`." ,
858
+ FutureWarning ,
859
+ stacklevel = find_stack_level (),
860
+ )
861
+ elif opt is True :
862
+ import pyarrow as pa
863
+
864
+ pa_dtype = pa .time64 ("us" )
865
+ from pandas .core .arrays .arrow import ArrowDtype
866
+
867
+ dtype = ArrowDtype (pa_dtype )
868
+
846
869
elif is_bool (val ):
847
870
dtype = np .dtype (np .bool_ )
848
871
You can’t perform that action at this time.
0 commit comments