-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
series.apply(pandas.to_datetime, convert_dtype=False) still converts dtype #14559
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
Not sure what you are trying to do, as The docstring of
So this keyword only applies when the function works elementwise. As mentioned above,
But again, your code does not feel idiomatic, so please clarify what you are trying to achieve. In many cases you don't want to keep this object dtype. Having the series a |
@jorisvandenbossche, I was under impression that >>> isinstance(pandas.to_datetime, numpy.ufunc)
False Anyway, In my case, my function receives different functions to apply on the series and thus it does not know beforehand whether it will get class Foo:
def __init__(self, generator):
self.dataframe = generator.generate()
def convert(self, name, converter):
self.dataframe[name] = self.dataframe[name].apply(converter, convert_dtype=False) In my case, it's much easier to describe the behavior of the Also, regardless of my use case, the behavior of the [1] if not in the case of |
I understand that you don't want to distinguish between elementwise functions or not in your application, and for that the use of
you can specify not to check the dtype
that is not true, as when creating a dataframe the default is to deduce the dtypes from the data you pass in If you want to keep object dtype, you can simply do For the specifics, the reason this does not work as documented for datetimes, is this:
Under the hood, if |
You mean using
In which case, I'm hitting the #14558 issue. I'll retest this idea with Pandas 0.20. Thank you. @jorisvandenbossche, OK, I think I can use one of the approaches you have suggested. Anyway, may I ask you to reopen this in order to track the issue between the behavior and the documentation? |
A small, complete example of the issue
Expected Output
Output of
pd.show_versions()
The text was updated successfully, but these errors were encountered: