File tree 3 files changed +12
-1
lines changed
3 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ Fixed regressions
22
22
Bug fixes
23
23
~~~~~~~~~
24
24
- Bug in :class: `Series ` constructor raising DeprecationWarning when ``index `` is a list of :class: `Series ` (:issue: `55228 `)
25
+ - Bug in :class: `Series ` when trying to cast date-like string inputs to :class: `ArrowDtype ` of ``pyarrow.timestamp `` (:issue: `56266 `)
25
26
- Bug in :meth: `Index.__getitem__ ` returning wrong result for Arrow dtypes and negative stepsize (:issue: `55832 `)
26
27
- Fixed bug in :func: `to_numeric ` converting to extension dtype for ``string[pyarrow_numpy] `` dtype (:issue: `56179 `)
27
28
- Fixed bug in :meth: `.DataFrameGroupBy.min ` and :meth: `.DataFrameGroupBy.max ` not preserving extension dtype for empty object (:issue: `55619 `)
Original file line number Diff line number Diff line change @@ -464,7 +464,7 @@ def _box_pa_array(
464
464
465
465
try :
466
466
pa_array = pa .array (value , type = pa_type , from_pandas = True )
467
- except pa .ArrowInvalid :
467
+ except ( pa .ArrowInvalid , pa . ArrowTypeError ) :
468
468
# GH50430: let pyarrow infer type, then cast
469
469
pa_array = pa .array (value , from_pandas = True )
470
470
Original file line number Diff line number Diff line change @@ -2994,3 +2994,13 @@ def test_arrow_floordiv():
2994
2994
expected = pd .Series ([- 2 ], dtype = "int64[pyarrow]" )
2995
2995
result = a // b
2996
2996
tm .assert_series_equal (result , expected )
2997
+
2998
+
2999
+ def test_string_to_datetime_parsing_cast ():
3000
+ # GH 56266
3001
+ string_dates = ["2020-01-01 04:30:00" , "2020-01-02 00:00:00" , "2020-01-03 00:00:00" ]
3002
+ result = pd .Series (string_dates , dtype = "timestamp[ns][pyarrow]" )
3003
+ expected = pd .Series (
3004
+ ArrowExtensionArray (pa .array (pd .to_datetime (string_dates ), from_pandas = True ))
3005
+ )
3006
+ tm .assert_series_equal (result , expected )
You can’t perform that action at this time.
0 commit comments