@@ -375,46 +375,60 @@ def unique(values):
375375 >>> pd.unique(pd.Series([2] + [1] * 5))
376376 array([2, 1])
377377
378- >>> pd.unique(pd.Series([pd.Timestamp('20160101'),
379- ... pd.Timestamp('20160101')]))
378+ >>> pd.unique(pd.Series([pd.Timestamp("20160101"), pd.Timestamp("20160101")]))
380379 array(['2016-01-01T00:00:00.000000000'], dtype='datetime64[ns]')
381380
382- >>> pd.unique(pd.Series([pd.Timestamp('20160101', tz='US/Eastern'),
383- ... pd.Timestamp('20160101', tz='US/Eastern')]))
384- array([Timestamp('2016-01-01 00:00:00-0500', tz='US/Eastern')],
385- dtype=object)
386-
387- >>> pd.unique(pd.Index([pd.Timestamp('20160101', tz='US/Eastern'),
388- ... pd.Timestamp('20160101', tz='US/Eastern')]))
381+ >>> pd.unique(
382+ ... pd.Series(
383+ ... [
384+ ... pd.Timestamp("20160101", tz="US/Eastern"),
385+ ... pd.Timestamp("20160101", tz="US/Eastern"),
386+ ... ]
387+ ... )
388+ ... )
389+ <DatetimeArray>
390+ ['2016-01-01 00:00:00-05:00']
391+ Length: 1, dtype: datetime64[ns, US/Eastern]
392+
393+ >>> pd.unique(
394+ ... pd.Index(
395+ ... [
396+ ... pd.Timestamp("20160101", tz="US/Eastern"),
397+ ... pd.Timestamp("20160101", tz="US/Eastern"),
398+ ... ]
399+ ... )
400+ ... )
389401 DatetimeIndex(['2016-01-01 00:00:00-05:00'],
390- ... dtype='datetime64[ns, US/Eastern]', freq=None)
402+ dtype='datetime64[ns, US/Eastern]',
403+ freq=None)
391404
392- >>> pd.unique(list(' baabc' ))
405+ >>> pd.unique(list(" baabc" ))
393406 array(['b', 'a', 'c'], dtype=object)
394407
395408 An unordered Categorical will return categories in the
396409 order of appearance.
397410
398- >>> pd.unique(pd.Series(pd.Categorical(list(' baabc' ))))
399- [b, a, c ]
400- Categories (3, object): [b, a, c ]
411+ >>> pd.unique(pd.Series(pd.Categorical(list(" baabc" ))))
412+ ['b', 'a', 'c' ]
413+ Categories (3, object): ['a', 'b', 'c' ]
401414
402- >>> pd.unique(pd.Series(pd.Categorical(list('baabc'),
403- ... categories=list('abc'))))
404- [b, a, c]
405- Categories (3, object): [b, a, c]
415+ >>> pd.unique(pd.Series(pd.Categorical(list("baabc"), categories=list("abc"))))
416+ ['b', 'a', 'c']
417+ Categories (3, object): ['a', 'b', 'c']
406418
407419 An ordered Categorical preserves the category ordering.
408420
409- >>> pd.unique(pd.Series(pd.Categorical(list('baabc'),
410- ... categories=list('abc'),
411- ... ordered=True)))
412- [b, a, c]
413- Categories (3, object): [a < b < c]
421+ >>> pd.unique(
422+ ... pd.Series(
423+ ... pd.Categorical(list("baabc"), categories=list("abc"), ordered=True)
424+ ... )
425+ ... )
426+ ['b', 'a', 'c']
427+ Categories (3, object): ['a' < 'b' < 'c']
414428
415429 An array of tuples
416430
417- >>> pd.unique([('a', 'b' ), ('b', 'a' ), ('a', 'c' ), ('b', 'a' )])
431+ >>> pd.unique([("a", "b" ), ("b", "a" ), ("a", "c" ), ("b", "a" )])
418432 array([('a', 'b'), ('b', 'a'), ('a', 'c')], dtype=object)
419433 """
420434 values = _ensure_arraylike (values )
0 commit comments