25 lines
456 B
Python
25 lines
456 B
Python
|
import numpy as np
|
||
|
|
||
|
from pandas import (
|
||
|
Categorical,
|
||
|
Series,
|
||
|
)
|
||
|
|
||
|
|
||
|
def test_nunique():
|
||
|
# basics.rst doc example
|
||
|
series = Series(np.random.randn(500))
|
||
|
series[20:500] = np.nan
|
||
|
series[10:20] = 5000
|
||
|
result = series.nunique()
|
||
|
assert result == 11
|
||
|
|
||
|
|
||
|
def test_nunique_categorical():
|
||
|
# GH#18051
|
||
|
ser = Series(Categorical([]))
|
||
|
assert ser.nunique() == 0
|
||
|
|
||
|
ser = Series(Categorical([np.nan]))
|
||
|
assert ser.nunique() == 0
|