You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, converting directly to StringDtype is not really safe unless you know you've got a str type:
>>>pd.Series([1,2, np.nan], dtype=str)[0]
'1'# string, works>>>pd.Series([1,2, np.nan], dtype="string")
ValueError# does not work>>>pd.Series([1,2, np.nan], dtype=str).astype("string")
# works>>>pd.Series([1,2, np.nan]).astype("string")
ValueError# does not work>>>pd.Series([1,2, np.nan]).astype(str).astype("string")
# works
The net result is that we have to wrap conversions, so in general will have to do x.astype(str).astype("string"), which seems unnecessary.
This extends to other conversions to StringDtype, e.g. for read_excel we have to do:
where directly setting dtype={"col_x": "string"} would seem more natural.
I think we should be able to convert directly to StringDtype by internally converting first to str, if needed. I might be missing some nuance why this is not allowed, though.
Any comment on loosening up here?
The text was updated successfully, but these errors were encountered:
Currently, converting directly to StringDtype is not really safe unless you know you've got a
str
type:The net result is that we have to wrap conversions, so in general will have to do
x.astype(str).astype("string")
, which seems unnecessary.This extends to other conversions to StringDtype, e.g. for
read_excel
we have to do:where directly setting
dtype={"col_x": "string"}
would seem more natural.I think we should be able to convert directly to StringDtype by internally converting first to
str
, if needed. I might be missing some nuance why this is not allowed, though.Any comment on loosening up here?
The text was updated successfully, but these errors were encountered: