File tree 1 file changed +32
-0
lines changed
1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change 10
10
MultiIndex ,
11
11
Series ,
12
12
date_range ,
13
+ Timestamp ,
13
14
)
14
15
import pandas ._testing as tm
15
16
from pandas .tests .generic .test_generic import Generic
@@ -87,6 +88,37 @@ def test_metadata_propagation_indiv_resample(self):
87
88
result = df .resample ("1T" )
88
89
self .check_metadata (df , result )
89
90
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
+
90
122
def test_metadata_propagation_indiv (self ):
91
123
# merging with override
92
124
# GH 6923
You can’t perform that action at this time.
0 commit comments