-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
TST: setitem preserving period[D] dtype #52704
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
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 |
---|---|---|
|
@@ -379,6 +379,15 @@ def test_setitem_complete_column_with_array(self): | |
assert expected["d"].dtype == arr.dtype | ||
tm.assert_frame_equal(df, expected) | ||
|
||
def test_setitem_periodd_dtype(self): | ||
# GH 39763 | ||
rng = period_range("2016-01-01", periods=9, freq="D", name="A") | ||
df = DataFrame(rng) | ||
expected = df.dtypes | ||
df.iloc[:] = rng._na_value | ||
result = df.dtypes | ||
tm.assert_equal(result, expected) | ||
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. Please construct the expected DataFrame and use 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'm a bit confused here, I thought that way but after executing this line # o/p of df.iloc[:] = rng._na_value
A
0 NaT
1 NaT
2 NaT
3 NaT
4 NaT
5 NaT
6 NaT
7 NaT
8 NaT
# And it's data type
# -> df.dtypes
A period[D]
dtype: object and that was a but for expected = pd.DataFrame({"A": ['NaT', 'NaT', 'NaT', 'NaT', 'NaT', 'NaT', 'NaT', 'NaT', 'NaT']})
expected.astype(obj.dtypes) # 1 did not work
expected.astype("period[D]") # 2 did not work
expected.dtypes
# o/p
A object
dtype: object as per your suggestion, we can create a new data frame using period_range and compare using I hope I'm able to describe the confusion clearly here. 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.
|
||
|
||
@pytest.mark.parametrize("dtype", ["f8", "i8", "u8"]) | ||
def test_setitem_bool_with_numeric_index(self, dtype): | ||
# GH#36319 | ||
|
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.
typo extra "d"
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.
Originally its
period[D]
but to name a function I thought this would be fine.But I think there are ways we can rename
..._period_d_dtpye(self)
..._period_dtype(self)
What do you think?
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.
_period_d_dtype
is fineThere 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.
Okay! sounds good 👍
Thanks