-
-
Notifications
You must be signed in to change notification settings - Fork 18.6k
BUG GH23451 Allow setting date in string index for Series #23495
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
Changes from 1 commit
9d03b80
ad7c8ef
70a0725
12d2f8a
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 |
---|---|---|
|
@@ -947,6 +947,9 @@ def _set_with(self, key, value): | |
except Exception: | ||
pass | ||
|
||
if isinstance(key, str): | ||
key = [key] | ||
|
||
if not isinstance(key, (list, Series, np.ndarray, Series)): | ||
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. Series is here twice :< can you remove 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 can be an elseif |
||
try: | ||
key = list(key) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -548,3 +548,9 @@ def test_minmax_nat_series(self, nat): | |
def test_minmax_nat_dataframe(self, nat): | ||
assert nat.min()[0] is pd.NaT | ||
assert nat.max()[0] is pd.NaT | ||
|
||
def test_set_dt_with_string_index(self): | ||
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. rename to test_setitem_with_string_index |
||
from datetime import date | ||
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. imports go at the top |
||
x = pd.Series([1, 2, 3], index=['Date', 'b', 'other']) | ||
x.Date = date.today() | ||
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. can you try this both as (parametrize) 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. I can't seem to figure out how to parametrize both these cases, as "Date" is being used in different contexts. What would be the variable(s) I parametrize and how would I use it with |
||
assert x.Date == date.today() |
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.
you might be able to make this is_scalar