@@ -375,46 +375,60 @@ def unique(values):
375
375
>>> pd.unique(pd.Series([2] + [1] * 5))
376
376
array([2, 1])
377
377
378
- >>> pd.unique(pd.Series([pd.Timestamp('20160101'),
379
- ... pd.Timestamp('20160101')]))
378
+ >>> pd.unique(pd.Series([pd.Timestamp("20160101"), pd.Timestamp("20160101")]))
380
379
array(['2016-01-01T00:00:00.000000000'], dtype='datetime64[ns]')
381
380
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
+ ... )
389
401
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)
391
404
392
- >>> pd.unique(list(' baabc' ))
405
+ >>> pd.unique(list(" baabc" ))
393
406
array(['b', 'a', 'c'], dtype=object)
394
407
395
408
An unordered Categorical will return categories in the
396
409
order of appearance.
397
410
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' ]
401
414
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']
406
418
407
419
An ordered Categorical preserves the category ordering.
408
420
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']
414
428
415
429
An array of tuples
416
430
417
- >>> pd.unique([('a', 'b' ), ('b', 'a' ), ('a', 'c' ), ('b', 'a' )])
431
+ >>> pd.unique([("a", "b" ), ("b", "a" ), ("a", "c" ), ("b", "a" )])
418
432
array([('a', 'b'), ('b', 'a'), ('a', 'c')], dtype=object)
419
433
"""
420
434
values = _ensure_arraylike (values )
0 commit comments