-
-
Notifications
You must be signed in to change notification settings - Fork 18k
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
BUG: unique() casts type pd.Timestamp
to numpy.datetime64
#35448
Comments
there have been a number of discussions about this - pls look for duplicate issues before opening a new one |
Thanks for your answer @jreback . |
I'll close this since I think it is covered by #22824
|
though having a dedicated issue for this might be ok (as that catch all unique issue brings up many topics) we cannot change this to return a DatetimeArray till 2.0 in any event (nor can we deprecate anything) |
@simonjayhawkins for what I can understand #22824 is a different issue. The problem of the current issue, is not that |
Let me add a clearer example: import pandas as pd
df = pd.DataFrame({"date": ["2019-02-10", "2019-02-11"]})
df["date"] = pd.to_datetime(df["date"])
print("Date Types in column date:")
for day in df["date"]:
print(type(day)) # this is pandas._libs.tslibs.timestamps.Timestamp
print("Unique date Types in column date:")
for day in df["date"].unique():
print(type(day)) # this is np.datetime64 The code returns:
|
OK but I don't think that's clear from the OP. Feel free to open a new issue. |
You do not think it is clear as in "I think it is covered by #22824"? |
The first case is iterating over a Series, the second case is iterating over a numpy array. An MRE doesn't need this comparison. just the output of .unique and the expected output. as @jreback states in #35448 (comment)
|
@simonjayhawkins please let me know if now is clearer. |
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandas.
(optional) I have confirmed this bug exists on the master branch of pandas.
Code Sample:
which returns:
Problem description
The function
unique()
should not cast the data type.Expected Output
types of
df_target["date"].unique()
should be the same as inset(df_target["date"].to_list())
. E.g.Returning:
Output of
pd.show_versions()
The text was updated successfully, but these errors were encountered: