Pandas version checks
-
[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.
-
[ ] I have confirmed this bug exists on the main branch of pandas.
Reproducible Example
import pandas as pd
df = pd.DataFrame(data={0: [0, 0, 3], 1: [1, 1, 0], "time": [0, 1, 2]})
df.set_index("time", inplace=True)
df.drop_duplicates(keep="last")
Issue Description
I get the following warning:
/home/tkoehne/apps/miniconda3/envs/testpd/lib/python3.10/site-packages/pandas/core/frame.py:6257: FutureWarning: In a future version, the Index constructor will not infer numeric dtypes when passed object-dtype sequences (matching Series behavior)
diff = Index(subset).difference(self.columns)
Expected Behavior
Internally, the changing of the index and subsequent checks for dropping shouldn't raise a FutureWarning, but rather adopt the future behavior by default.
Installed Versions
Comment From: dannyi96
Have confirmed that this issue exists in latest released version 1.5 but is fixed in main ( for next 2.0 release ) via changes made in PR #49458 (in file pandas/core/indexes/base.py ).
[ CC: @mroeschke ] would this be a change which would need to be backported to 1.5 as well ? or its fine for fix to be in next 2.0 release ?
Comment From: mroeschke
Looks like https://github.com/pandas-dev/pandas/pull/49458 fixed this because FutureWarning was removed to enforce the deprecation; therefore, it can't be backported to 1.5.2 since it would be a breaking change.
Overall this will be fixed in 2.0. A backport PR would be accepted, but it needs to be based on the 1.5.x branch.
Comment From: phofl
I can see this on 1.4.4 but neither on 1.5.0 nor on 1.5.1,
Comment From: dannyi96
@phofl yes, you're right ( my bad, the issue is present on older versions 1.4.x & is handled in 1.5.x ) I believe we can close this issue.