@@ -375,60 +375,48 @@ 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"), pd.Timestamp("20160101")]))
378
+ >>> pd.unique(pd.Series([pd.Timestamp('20160101'),
379
+ ... pd.Timestamp('20160101')]))
379
380
array(['2016-01-01T00:00:00.000000000'], dtype='datetime64[ns]')
380
381
381
- >>> pd.unique(
382
- ... pd.Series(
383
- ... [
384
- ... pd.Timestamp("20160101", tz="US/Eastern"),
385
- ... pd.Timestamp("20160101", tz="US/Eastern"),
386
- ... ]
387
- ... )
388
- ... )
382
+ >>> pd.unique(pd.Series([pd.Timestamp('20160101', tz='US/Eastern'),
383
+ ... pd.Timestamp('20160101', tz='US/Eastern')]))
389
384
<DatetimeArray>
390
385
['2016-01-01 00:00:00-05:00']
391
386
Length: 1, dtype: datetime64[ns, US/Eastern]
392
387
393
- >>> pd.unique(
394
- ... pd.Index(
395
- ... [
396
- ... pd.Timestamp("20160101", tz="US/Eastern"),
397
- ... pd.Timestamp("20160101", tz="US/Eastern"),
398
- ... ]
399
- ... )
400
- ... )
388
+ >>> pd.unique(pd.Index([pd.Timestamp('20160101', tz='US/Eastern'),
389
+ ... pd.Timestamp('20160101', tz='US/Eastern')]))
401
390
DatetimeIndex(['2016-01-01 00:00:00-05:00'],
402
391
dtype='datetime64[ns, US/Eastern]',
403
392
freq=None)
404
393
405
- >>> pd.unique(list(" baabc" ))
394
+ >>> pd.unique(list(' baabc' ))
406
395
array(['b', 'a', 'c'], dtype=object)
407
396
408
397
An unordered Categorical will return categories in the
409
398
order of appearance.
410
399
411
- >>> pd.unique(pd.Series(pd.Categorical(list(" baabc" ))))
400
+ >>> pd.unique(pd.Series(pd.Categorical(list(' baabc' ))))
412
401
['b', 'a', 'c']
413
402
Categories (3, object): ['a', 'b', 'c']
414
403
415
- >>> pd.unique(pd.Series(pd.Categorical(list("baabc"), categories=list("abc"))))
404
+ >>> pd.unique(pd.Series(pd.Categorical(list('baabc'),
405
+ ... categories=list('abc'))))
416
406
['b', 'a', 'c']
417
407
Categories (3, object): ['a', 'b', 'c']
418
408
419
409
An ordered Categorical preserves the category ordering.
420
410
421
- >>> pd.unique(
422
- ... pd.Series(
423
- ... pd.Categorical(list("baabc"), categories=list("abc"), ordered=True)
424
- ... )
425
- ... )
411
+ >>> pd.unique(pd.Series(pd.Categorical(list('baabc'),
412
+ ... categories=list('abc'),
413
+ ... ordered=True)))
426
414
['b', 'a', 'c']
427
415
Categories (3, object): ['a' < 'b' < 'c']
428
416
429
417
An array of tuples
430
418
431
- >>> pd.unique([("a", "b" ), ("b", "a" ), ("a", "c" ), ("b", "a" )])
419
+ >>> pd.unique([('a', 'b' ), ('b', 'a' ), ('a', 'c' ), ('b', 'a' )])
432
420
array([('a', 'b'), ('b', 'a'), ('a', 'c')], dtype=object)
433
421
"""
434
422
values = _ensure_arraylike (values )
0 commit comments