File tree 3 files changed +20
-3
lines changed 3 files changed +20
-3
lines changed Original file line number Diff line number Diff line change @@ -923,7 +923,12 @@ def __init__(
923
923
924
924
NDFrame .__init__ (self , mgr )
925
925
926
- if original_dtype is None and is_pandas_object and data_dtype == np .object_ :
926
+ if (
927
+ original_dtype is None
928
+ and is_pandas_object
929
+ and data_dtype == np .object_
930
+ and self .dtypes .iloc [0 ] != "str"
931
+ ):
927
932
if self .dtypes .iloc [0 ] != data_dtype :
928
933
warnings .warn (
929
934
"Dtype inference on a pandas object "
Original file line number Diff line number Diff line change @@ -575,7 +575,13 @@ def __new__(
575
575
576
576
arr = klass ._ensure_array (arr , arr .dtype , copy = False )
577
577
result = klass ._simple_new (arr , name , refs = refs )
578
- if dtype is None and is_pandas_object and data_dtype == np .object_ :
578
+ # TODO: also verify this check
579
+ if (
580
+ dtype is None
581
+ and is_pandas_object
582
+ and data_dtype == np .object_
583
+ and result .dtype != "str"
584
+ ):
579
585
if result .dtype != data_dtype :
580
586
warnings .warn (
581
587
"Dtype inference on a pandas object "
Original file line number Diff line number Diff line change @@ -593,7 +593,13 @@ def __init__(
593
593
self .name = name
594
594
self ._set_axis (0 , index )
595
595
596
- if original_dtype is None and is_pandas_object and data_dtype == np .object_ :
596
+ # TODO: verify we're silencing the warning correctly here
597
+ if (
598
+ original_dtype is None
599
+ and is_pandas_object
600
+ and data_dtype == np .object_
601
+ and self .dtype != "str"
602
+ ):
597
603
if self .dtype != data_dtype :
598
604
warnings .warn (
599
605
"Dtype inference on a pandas object "
You can’t perform that action at this time.
0 commit comments