-
[x] I have checked that this issue has not already been reported.
-
[x] I have confirmed this bug exists on the latest version of pandas.
-
[x] (optional) I have confirmed this bug exists on the master branch of pandas.
Note: Please read this guide detailing how to provide the necessary information for us to reproduce your bug.
Code Sample, a copy-pastable example
DataFrame(["foo", "bar", "baz"]).astype(bytes)
As discussed in #39484 we do not want to get numpy string dtypes here. This should have dtype object
Comment From: jreback
this is a breaking change, but was never intended and we have 0 support for S (or B) types as native pandas types.
Comment From: jorisvandenbossche
Can we deprecate this in some way first?
And what do you exactly want to change? Only the resulting dtype to be object (but still do the conversion to bytes), or actually disallow casting to bytest altogether?
Comment From: jorisvandenbossche
One option would be to deprecate astype(bytes)
or astype(np.dtype("S"))
, and let users use another method to actually convert values to bytes (eg s.map(bytes)
might also do that?)
Comment From: simonjayhawkins
removing the milestone
Comment From: jbrockmendel
Related: when we pass a np.dtype("S") ndarray to Series or DataFrame do we cast to object? ATM we do this for only a few variants of the DataFrame constructor, not for Series
Comment From: jbrockmendel
Resolving this would fix #52373.