3
3
from string import ascii_lowercase
4
4
5
5
import numpy as np
6
+ import pyarrow as pa
6
7
import pytest
7
8
8
9
from pandas ._libs .tslibs import iNaT
@@ -1052,7 +1053,31 @@ def scipy_sem(*args, **kwargs):
1052
1053
[
1053
1054
("sum" , [- 1.0 , 1.2 , - 1.1 , 1.5 , np .nan , 1.0 ]),
1054
1055
("sum" , ["foo" , "bar" , "baz" , "foo" , pd .NA , "foo" ]),
1056
+ (
1057
+ "sum" ,
1058
+ Series (pd .array ([- 1.0 , 1.2 , - 1.1 , 1.5 , np .nan , 1.0 ], dtype = "Float64" )),
1059
+ ),
1060
+ (
1061
+ "sum" ,
1062
+ Series (
1063
+ pd .array (
1064
+ [1.0 , 2.0 , 3.0 , np .nan , 4.0 , 5.0 ], dtype = pd .ArrowDtype (pa .float64 ())
1065
+ )
1066
+ ),
1067
+ ),
1055
1068
("min" , [- 1.0 , 1.2 , - 1.1 , 1.5 , np .nan , 1.0 ]),
1069
+ (
1070
+ "min" ,
1071
+ Series (pd .array ([- 1.0 , 1.2 , - 1.1 , 1.5 , np .nan , 1.0 ], dtype = "Float64" )),
1072
+ ),
1073
+ (
1074
+ "min" ,
1075
+ Series (
1076
+ pd .array (
1077
+ [1.0 , 2.0 , 3.0 , np .nan , 4.0 , 5.0 ], dtype = pd .ArrowDtype (pa .float64 ())
1078
+ )
1079
+ ),
1080
+ ),
1056
1081
(
1057
1082
"min" ,
1058
1083
[
@@ -1076,6 +1101,18 @@ def scipy_sem(*args, **kwargs):
1076
1101
],
1077
1102
),
1078
1103
("max" , [- 1.0 , 1.2 , - 1.1 , 1.5 , np .nan , 1.0 ]),
1104
+ (
1105
+ "max" ,
1106
+ Series (pd .array ([- 1.0 , 1.2 , - 1.1 , 1.5 , np .nan , 1.0 ], dtype = "Float64" )),
1107
+ ),
1108
+ (
1109
+ "max" ,
1110
+ Series (
1111
+ pd .array (
1112
+ [1.0 , 2.0 , 3.0 , np .nan , 4.0 , 5.0 ], dtype = pd .ArrowDtype (pa .float64 ())
1113
+ )
1114
+ ),
1115
+ ),
1079
1116
(
1080
1117
"max" ,
1081
1118
[
@@ -1099,6 +1136,18 @@ def scipy_sem(*args, **kwargs):
1099
1136
],
1100
1137
),
1101
1138
("mean" , [- 1.0 , 1.2 , - 1.1 , 1.5 , np .nan , 1.0 ]),
1139
+ (
1140
+ "mean" ,
1141
+ Series (pd .array ([- 1.0 , 1.2 , - 1.1 , 1.5 , np .nan , 1.0 ], dtype = "Float64" )),
1142
+ ),
1143
+ (
1144
+ "mean" ,
1145
+ Series (
1146
+ pd .array (
1147
+ [1.0 , 2.0 , 3.0 , np .nan , 4.0 , 5.0 ], dtype = pd .ArrowDtype (pa .float64 ())
1148
+ )
1149
+ ),
1150
+ ),
1102
1151
(
1103
1152
"mean" ,
1104
1153
[
@@ -1122,6 +1171,18 @@ def scipy_sem(*args, **kwargs):
1122
1171
],
1123
1172
),
1124
1173
("median" , [- 1.0 , 1.2 , - 1.1 , 1.5 , np .nan , 1.0 ]),
1174
+ (
1175
+ "median" ,
1176
+ Series (pd .array ([- 1.0 , 1.2 , - 1.1 , 1.5 , np .nan , 1.0 ], dtype = "Float64" )),
1177
+ ),
1178
+ (
1179
+ "median" ,
1180
+ Series (
1181
+ pd .array (
1182
+ [1.0 , 2.0 , 3.0 , np .nan , 4.0 , 5.0 ], dtype = pd .ArrowDtype (pa .float64 ())
1183
+ )
1184
+ ),
1185
+ ),
1125
1186
(
1126
1187
"median" ,
1127
1188
[
@@ -1145,9 +1206,57 @@ def scipy_sem(*args, **kwargs):
1145
1206
],
1146
1207
),
1147
1208
("prod" , [- 1.0 , 1.2 , - 1.1 , 1.5 , np .nan , 1.0 ]),
1209
+ (
1210
+ "prod" ,
1211
+ Series (pd .array ([- 1.0 , 1.2 , - 1.1 , 1.5 , np .nan , 1.0 ], dtype = "Float64" )),
1212
+ ),
1213
+ (
1214
+ "prod" ,
1215
+ Series (
1216
+ pd .array (
1217
+ [1.0 , 2.0 , 3.0 , np .nan , 4.0 , 5.0 ], dtype = pd .ArrowDtype (pa .float64 ())
1218
+ )
1219
+ ),
1220
+ ),
1148
1221
("sem" , [- 1.0 , 1.2 , - 1.1 , 1.5 , np .nan , 1.0 ]),
1222
+ (
1223
+ "sem" ,
1224
+ Series (pd .array ([- 1.0 , 1.2 , - 1.1 , 1.5 , np .nan , 1.0 ], dtype = "Float64" )),
1225
+ ),
1226
+ (
1227
+ "sem" ,
1228
+ Series (
1229
+ pd .array (
1230
+ [1.0 , 2.0 , 3.0 , np .nan , 4.0 , 5.0 ], dtype = pd .ArrowDtype (pa .float64 ())
1231
+ )
1232
+ ),
1233
+ ),
1149
1234
("std" , [- 1.0 , 1.2 , - 1.1 , 1.5 , np .nan , 1.0 ]),
1235
+ (
1236
+ "std" ,
1237
+ Series (pd .array ([- 1.0 , 1.2 , - 1.1 , 1.5 , np .nan , 1.0 ], dtype = "Float64" )),
1238
+ ),
1239
+ (
1240
+ "std" ,
1241
+ Series (
1242
+ pd .array (
1243
+ [1.0 , 2.0 , 3.0 , np .nan , 4.0 , 5.0 ], dtype = pd .ArrowDtype (pa .float64 ())
1244
+ )
1245
+ ),
1246
+ ),
1150
1247
("var" , [- 1.0 , 1.2 , - 1.1 , 1.5 , np .nan , 1.0 ]),
1248
+ (
1249
+ "var" ,
1250
+ Series (pd .array ([- 1.0 , 1.2 , - 1.1 , 1.5 , np .nan , 1.0 ], dtype = "Float64" )),
1251
+ ),
1252
+ (
1253
+ "var" ,
1254
+ Series (
1255
+ pd .array (
1256
+ [1.0 , 2.0 , 3.0 , np .nan , 4.0 , 5.0 ], dtype = pd .ArrowDtype (pa .float64 ())
1257
+ )
1258
+ ),
1259
+ ),
1151
1260
("any" , [- 1.0 , 1.2 , - 1.1 , 1.5 , np .nan , 1.0 ]),
1152
1261
("all" , [- 1.0 , 1.2 , - 1.1 , 1.5 , np .nan , 1.0 ]),
1153
1262
("skew" , [- 1.0 , 1.2 , - 1.1 , 1.5 , np .nan , 1.0 ]),
@@ -1163,7 +1272,7 @@ def test_skipna_reduction_ops_cython(reduction_method, values):
1163
1272
expected = gb .apply (
1164
1273
lambda x : getattr (x , reduction_method )(skipna = False ), include_groups = False
1165
1274
)
1166
- tm .assert_frame_equal (result_cython , expected , check_exact = False )
1275
+ tm .assert_frame_equal (result_cython , expected , check_exact = False , check_dtype = False )
1167
1276
1168
1277
1169
1278
@pytest .mark .parametrize (
@@ -1310,4 +1419,4 @@ def test_groupby_std_datetimelike():
1310
1419
td4 = pd .Timedelta ("2886 days 00:42:34.664668096" )
1311
1420
exp_ser = Series ([td1 * 2 , td1 , td1 , td1 , td4 ], index = np .arange (5 ))
1312
1421
expected = DataFrame ({"A" : exp_ser , "B" : exp_ser , "C" : exp_ser })
1313
- tm .assert_frame_equal (result , expected )
1422
+ tm .assert_frame_equal (result , expected )
0 commit comments