Skip to content

Commit 4c4bcf9

Browse files
committed
1 parent 6c4ec55 commit 4c4bcf9

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

pandas/tests/generic/test_frame.py

+32
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
MultiIndex,
1111
Series,
1212
date_range,
13+
Timestamp,
1314
)
1415
import pandas._testing as tm
1516
from pandas.tests.generic.test_generic import Generic
@@ -87,6 +88,37 @@ def test_metadata_propagation_indiv_resample(self):
8788
result = df.resample("1T")
8889
self.check_metadata(df, result)
8990

91+
def test_column_types_consistent(self):
92+
# GH 26779
93+
df = DataFrame(
94+
data={
95+
"channel": [1, 2, 3],
96+
"A": ["String 1", np.NaN, "String 2"],
97+
"B": [
98+
Timestamp("2019-06-11 11:00:00"),
99+
np.NaN,
100+
Timestamp("2019-06-11 12:00:00"),
101+
],
102+
}
103+
)
104+
df2 = pd.DataFrame(
105+
data={"A": ["String 3"], "B": [Timestamp("2019-06-11 12:00:00")]}
106+
)
107+
# Change Columns A and B to df2.values wherever Column A is NaN
108+
df.loc[df["A"].isna(), ["A", "B"]] = df2.values
109+
expected = DataFrame(
110+
data={
111+
"channel": [1, 2, 3],
112+
"A": ["String 1", "String 3", "String 2"],
113+
"B": [
114+
Timestamp("2019-06-11 11:00:00"),
115+
Timestamp("2019-06-11 12:00:00"),
116+
Timestamp("2019-06-11 12:00:00"),
117+
],
118+
}
119+
)
120+
tm.assert_frame_equal(df, expected)
121+
90122
def test_metadata_propagation_indiv(self):
91123
# merging with override
92124
# GH 6923

0 commit comments

Comments
 (0)