Inzynierka/Lib/site-packages/pandas/tests/series/methods/test_nunique.py

25 lines
456 B
Python
Raw Normal View History

2023-06-02 12:51:02 +02:00
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