-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Cannot convert a datetimelike to 'str' with astype #9757
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
this is string formatting and not what astype does which is convert to a fixed width string dtype which is not the same as a str representation that's why this is not allowed it's possible that astype should just do the default formatting but I'd like to see some justification for this which addresses the points above |
This conversion is explicitly allowed for every other type (e.g., conversion to string is checked for directly in In numpy, a call to
That might be a better choice, but it's not what's currently being done for types other than
I actually can't get
|
I personally expect conversion to 'str' to always work and default to I was trying to convert an entire DataFrame to 'str' (for quick displaying purposes, nothing fancy).
does what I had in mind but adds an useless conversion. |
Actually, it looks like I'm confused about fixed-width string dtypes. Is it even possible to store such a thing in a Series or DataFrame? I can't seem to find any way. |
fixed width string dtypes are not supported and converted to object |
It's true that we don't support fixed width string dtypes, but it would be nice for |
I also see no reason to not let Apart from that, we could maybe also use a separate formatting function (similar to |
closed by #9758 |
I find this surprising:
str(pd.Timestamp) works though, so why astype shouldn't?
Also the type representation "|S0" is not entirely clear to me.
The text was updated successfully, but these errors were encountered: