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