Skip to content

Commit b0bc1ec

Browse files
shiv-iofeefladder
authored andcommitted
TST: test_column_types_consistent (pandas-dev#42725)
1 parent 7c031b2 commit b0bc1ec

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

pandas/tests/indexing/test_loc.py

+31
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,37 @@ def test_setitem_from_duplicate_axis(self):
143143
)
144144
tm.assert_frame_equal(df, expected)
145145

146+
def test_column_types_consistent(self):
147+
# GH 26779
148+
df = DataFrame(
149+
data={
150+
"channel": [1, 2, 3],
151+
"A": ["String 1", np.NaN, "String 2"],
152+
"B": [
153+
Timestamp("2019-06-11 11:00:00"),
154+
pd.NaT,
155+
Timestamp("2019-06-11 12:00:00"),
156+
],
157+
}
158+
)
159+
df2 = DataFrame(
160+
data={"A": ["String 3"], "B": [Timestamp("2019-06-11 12:00:00")]}
161+
)
162+
# Change Columns A and B to df2.values wherever Column A is NaN
163+
df.loc[df["A"].isna(), ["A", "B"]] = df2.values
164+
expected = DataFrame(
165+
data={
166+
"channel": [1, 2, 3],
167+
"A": ["String 1", "String 3", "String 2"],
168+
"B": [
169+
Timestamp("2019-06-11 11:00:00"),
170+
Timestamp("2019-06-11 12:00:00"),
171+
Timestamp("2019-06-11 12:00:00"),
172+
],
173+
}
174+
)
175+
tm.assert_frame_equal(df, expected)
176+
146177

147178
class TestLoc2:
148179
# TODO: better name, just separating out things that rely on base class

0 commit comments

Comments
 (0)