Skip to content

Commit 3f1ffde

Browse files
nealxmNeal Muppidi
authored andcommitted
TST: add tests for using .at() with DateTime indexes (pandas-dev#48286)
* add tests outlined in GH29709 * fix styling error caught by github actions * made changes based on suggestions from patrick * fix pep8 mistakes * remove usage of to_datetime() * fix error in pre-commit checks also move my new test to the bottom of the class since it was not put in the right place before Co-authored-by: Neal Muppidi <[email protected]>
1 parent 079ef5f commit 3f1ffde

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

pandas/tests/indexing/test_at.py

+14
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
CategoricalDtype,
1111
CategoricalIndex,
1212
DataFrame,
13+
DatetimeIndex,
1314
MultiIndex,
1415
Series,
1516
Timestamp,
@@ -109,6 +110,19 @@ def test_at_setitem_multiindex(self):
109110
)
110111
tm.assert_frame_equal(df, expected)
111112

113+
@pytest.mark.parametrize("row", (Timestamp("2019-01-01"), "2019-01-01"))
114+
def test_at_datetime_index(self, row):
115+
df = DataFrame(
116+
data=[[1] * 2], index=DatetimeIndex(data=["2019-01-01", "2019-01-02"])
117+
)
118+
expected = DataFrame(
119+
data=[[0.5, 1], [1.0, 1]],
120+
index=DatetimeIndex(data=["2019-01-01", "2019-01-02"]),
121+
)
122+
123+
df.at[row, 0] = 0.5
124+
tm.assert_frame_equal(df, expected)
125+
112126

113127
class TestAtSetItemWithExpansion:
114128
def test_at_setitem_expansion_series_dt64tz_value(self, tz_naive_fixture):

0 commit comments

Comments
 (0)