@@ -1173,12 +1173,12 @@ def test_dropna(self):
1173
1173
)
1174
1174
1175
1175
tm .assert_series_equal (
1176
- Series ([True , True , False , None ]).value_counts (dropna = True ),
1177
- Series ([2 , 1 ], index = [True , False ]),
1176
+ Series ([True ] * 3 + [ False ] * 2 + [ None ] * 5 ).value_counts (dropna = True ),
1177
+ Series ([3 , 2 ], index = [True , False ]),
1178
1178
)
1179
1179
tm .assert_series_equal (
1180
- Series ([True , True , False , None ]).value_counts (dropna = False ),
1181
- Series ([2 , 1 , 1 ], index = [True , np .nan , False ]),
1180
+ Series ([True ] * 5 + [ False ] * 3 + [ None ] * 2 ).value_counts (dropna = False ),
1181
+ Series ([5 , 3 , 2 ], index = [True , False , np .nan ]),
1182
1182
)
1183
1183
tm .assert_series_equal (
1184
1184
Series ([10.3 , 5.0 , 5.0 ]).value_counts (dropna = True ),
@@ -1194,26 +1194,24 @@ def test_dropna(self):
1194
1194
Series ([2 , 1 ], index = [5.0 , 10.3 ]),
1195
1195
)
1196
1196
1197
- # 32-bit linux has a different ordering
1198
- if IS64 :
1199
- result = Series ([10.3 , 5.0 , 5.0 , None ]).value_counts (dropna = False )
1200
- expected = Series ([2 , 1 , 1 ], index = [5.0 , np .nan , 10.3 ])
1201
- tm .assert_series_equal (result , expected )
1197
+ result = Series ([10.3 , 10.3 , 5.0 , 5.0 , 5.0 , None ]).value_counts (dropna = False )
1198
+ expected = Series ([3 , 2 , 1 ], index = [5.0 , 10.3 , np .nan ])
1199
+ tm .assert_series_equal (result , expected )
1202
1200
1203
1201
def test_value_counts_normalized (self ):
1204
1202
# GH12558
1205
- s = Series ([1 , 2 , np . nan , np . nan , np .nan ])
1203
+ s = Series ([1 ] * 2 + [ 2 ] * 3 + [ np .nan ] * 5 )
1206
1204
dtypes = (np .float64 , object , "M8[ns]" )
1207
1205
for t in dtypes :
1208
1206
s_typed = s .astype (t )
1209
1207
result = s_typed .value_counts (normalize = True , dropna = False )
1210
1208
expected = Series (
1211
- [0.6 , 0.2 , 0.2 ], index = Series ([np .nan , 1 .0 , 2 .0 ], dtype = t )
1209
+ [0.5 , 0.3 , 0.2 ], index = Series ([np .nan , 2 .0 , 1 .0 ], dtype = t )
1212
1210
)
1213
1211
tm .assert_series_equal (result , expected )
1214
1212
1215
1213
result = s_typed .value_counts (normalize = True , dropna = True )
1216
- expected = Series ([0.5 , 0.5 ], index = Series ([1 .0 , 2 .0 ], dtype = t ))
1214
+ expected = Series ([0.6 , 0.4 ], index = Series ([2 .0 , 1 .0 ], dtype = t ))
1217
1215
tm .assert_series_equal (result , expected )
1218
1216
1219
1217
def test_value_counts_uint64 (self ):
0 commit comments