ai-content-maker/.venv/Lib/site-packages/pandas/tests/series/methods/test_nunique.py

25 lines
456 B
Python
Raw Permalink Normal View History

2024-05-03 04:18:51 +03: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