@@ -132,25 +132,30 @@ def test_types_concat() -> None:
132
132
s = pd .Series ([0 , 1 , - 10 ])
133
133
s2 = pd .Series ([7 , - 5 , 10 ])
134
134
135
- check (assert_type (pd .concat ([s , s2 ]), pd .Series ), pd .Series )
135
+ check (assert_type (pd .concat ([s , s2 ]), " pd.Series[int]" ), pd .Series , np . integer )
136
136
check (assert_type (pd .concat ([s , s2 ], axis = 1 ), pd .DataFrame ), pd .DataFrame )
137
137
check (
138
- assert_type (pd .concat ([s , s2 ], keys = ["first" , "second" ], sort = True ), pd .Series ),
138
+ assert_type (
139
+ pd .concat ([s , s2 ], keys = ["first" , "second" ], sort = True ), "pd.Series[int]"
140
+ ),
139
141
pd .Series ,
142
+ np .integer ,
140
143
)
141
144
check (
142
145
assert_type (
143
146
pd .concat ([s , s2 ], keys = ["first" , "second" ], names = ["source" , "row" ]),
144
- pd .Series ,
147
+ " pd.Series[int]" ,
145
148
),
146
149
pd .Series ,
150
+ np .integer ,
147
151
)
148
152
check (
149
153
assert_type (
150
154
pd .concat ([s , s2 ], keys = ["first" , "second" ], names = None ),
151
- pd .Series ,
155
+ " pd.Series[int]" ,
152
156
),
153
157
pd .Series ,
158
+ np .integer ,
154
159
)
155
160
156
161
# Depends on the axis
@@ -236,6 +241,37 @@ def test_types_concat() -> None:
236
241
check (assert_type (pd .concat ([pd .DataFrame (), data ]), pd .DataFrame ), pd .DataFrame )
237
242
238
243
244
+ def test_concat_series_mixed_numeric () -> None :
245
+ """Test concatenation of Series with mixed numeric types.
246
+
247
+ Derived from test_types_concat."""
248
+ s = pd .Series ([0 , 1 , - 10 ])
249
+ s2 = pd .Series ([7.0 , - 5 , 10 ])
250
+
251
+ check (assert_type (pd .concat ([s , s2 ]), pd .Series ), pd .Series , np .floating )
252
+ check (
253
+ assert_type (pd .concat ([s , s2 ], keys = ["first" , "second" ], sort = True ), pd .Series ),
254
+ pd .Series ,
255
+ np .floating ,
256
+ )
257
+ check (
258
+ assert_type (
259
+ pd .concat ([s , s2 ], keys = ["first" , "second" ], names = ["source" , "row" ]),
260
+ pd .Series ,
261
+ ),
262
+ pd .Series ,
263
+ np .floating ,
264
+ )
265
+ check (
266
+ assert_type (
267
+ pd .concat ([s , s2 ], keys = ["first" , "second" ], names = None ),
268
+ pd .Series ,
269
+ ),
270
+ pd .Series ,
271
+ np .floating ,
272
+ )
273
+
274
+
239
275
def test_concat_args () -> None :
240
276
df = pd .DataFrame (data = {"col1" : [1 , 2 ], "col2" : [3 , 4 ]})
241
277
df2 = pd .DataFrame (data = {"col1" : [10 , 20 ], "col2" : [30 , 40 ]}, index = [2 , 3 ])
0 commit comments