-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
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: Added deprecation warning to Timestamp constructor #61149
base: main
Are you sure you want to change the base?
Changes from all commits
3639fd7
951ffb5
9ff8871
4d46206
bd4f286
d4821e5
cbbeae1
17f4fe7
32242c0
fe341cf
3eb2271
6d81c60
3e26a62
b9f2aef
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,7 +39,10 @@ | |
to_timedelta, | ||
) | ||
import pandas._testing as tm | ||
from pandas.api.types import is_scalar | ||
from pandas.api.types import ( | ||
is_datetime64_any_dtype, | ||
is_scalar, | ||
) | ||
from pandas.core.indexing import _one_ellipsis_message | ||
from pandas.tests.indexing.common import check_indexing_smoketest_or_raises | ||
|
||
|
@@ -2084,7 +2087,21 @@ def test_loc_setitem_with_expansion_nonunique_index(self, index): | |
assert key not in index # otherwise test is invalid | ||
# TODO: using a tuple key breaks here in many cases | ||
|
||
exp_index = index.insert(len(index), key) | ||
msg = "Passing an empty string to Timestamp" | ||
contains_datetime = False | ||
if isinstance(index, MultiIndex): | ||
for i in range(index.nlevels): | ||
if is_datetime64_any_dtype(index.get_level_values(i)): | ||
contains_datetime = True | ||
break | ||
if contains_datetime: | ||
with tm.assert_produces_warning(FutureWarning, match=msg): | ||
exp_index = index.insert(len(index), key) | ||
Comment on lines
+2098
to
+2099
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This looks problematic - the warning message will say not to pass If you want any assistance in how to change, let me know and I'm happy to take a look. |
||
else: | ||
exp_index = index.insert(len(index), key) | ||
else: | ||
exp_index = index.insert(len(index), key) | ||
|
||
if isinstance(index, MultiIndex): | ||
assert exp_index[-1][0] == key | ||
else: | ||
|
@@ -2094,19 +2111,32 @@ def test_loc_setitem_with_expansion_nonunique_index(self, index): | |
|
||
# Add new row, but no new columns | ||
df = orig.copy() | ||
df.loc[key, 0] = N | ||
if contains_datetime: | ||
with tm.assert_produces_warning(FutureWarning, match=msg): | ||
df.loc[key, 0] = N | ||
else: | ||
df.loc[key, 0] = N | ||
tm.assert_frame_equal(df, expected) | ||
|
||
# add new row on a Series | ||
ser = orig.copy()[0] | ||
ser.loc[key] = N | ||
if contains_datetime: | ||
with tm.assert_produces_warning(FutureWarning, match=msg): | ||
ser.loc[key] = N | ||
else: | ||
ser.loc[key] = N | ||
tm.assert_frame_equal(df, expected) | ||
# the series machinery lets us preserve int dtype instead of float | ||
expected = expected[0].astype(np.int64) | ||
tm.assert_series_equal(ser, expected) | ||
|
||
# add new row and new column | ||
df = orig.copy() | ||
df.loc[key, 1] = N | ||
if contains_datetime: | ||
with tm.assert_produces_warning(FutureWarning, match=msg): | ||
df.loc[key, 1] = N | ||
else: | ||
df.loc[key, 1] = N | ||
expected = DataFrame( | ||
{0: list(arr) + [np.nan], 1: [np.nan] * N + [float(N)]}, | ||
index=exp_index, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add
Use `pd.NaT` directly instead.