@@ -247,33 +247,19 @@ def test_nunique(self, index_or_series_obj):
247247
248248 def test_value_counts (self , index_or_series_obj ):
249249 orig = index_or_series_obj
250- obj = orig .copy ()
251- klass = type (obj )
252- values = obj ._values
250+ obj = multiply_values (orig .copy ())
253251
254252 if orig .duplicated ().any ():
253+ # FIXME: duplicated values should work.
255254 pytest .xfail (
256255 "The test implementation isn't flexible enough to deal"
257256 " with duplicated values. This isn't a bug in the"
258257 " application code, but in the test code."
259258 )
260259
261- # create repeated values, 'n'th element is repeated by n+1 times
262- if isinstance (obj , Index ):
263- expected_index = Index (obj [::- 1 ])
264- expected_index .name = None
265- obj = obj .repeat (range (1 , len (obj ) + 1 ))
266- else :
267- expected_index = Index (values [::- 1 ])
268- idx = obj .index .repeat (range (1 , len (obj ) + 1 ))
269- # take-based repeat
270- indices = np .repeat (np .arange (len (obj )), range (1 , len (obj ) + 1 ))
271- rep = values .take (indices )
272- obj = klass (rep , index = idx )
273-
274- # check values has the same dtype as the original
275- assert obj .dtype == orig .dtype
276-
260+ expected_index = Index (orig .values [::- 1 ], dtype = orig .dtype )
261+ if is_datetime64tz_dtype (obj ):
262+ expected_index = expected_index .normalize ()
277263 expected_s = Series (
278264 range (len (orig ), 0 , - 1 ), index = expected_index , dtype = "int64"
279265 )
0 commit comments