vDataFrame[].nunique

In [ ]:
vDataFrame[].nunique(approx: bool = True)

Aggregates the vColumn by cardinality.

Parameters

Name Type Optional Description
approx
bool
If set to True, the approximate cardinality is returned. Setting this parameter to false will give exact results, but decrease performance.

Returns

int : vColumn cardinality (or approximate cardinality).

Example

In [54]:
from verticapy.datasets import load_market
market = load_market()
display(market)
123
Price
Float
Abc
Form
Varchar(32)
Abc
Name
Varchar(32)
11.1193087167FreshAcorn squash
21.1722478842FreshAcorn squash
31.56751539145FreshApples
41.6155336441FreshApples
50.5104657455FrozenApples
60.537867915537FrozenApples
70.6311325278Ready to drinkApples
80.727287713105Ready to drinkApples
97.3309645323DriedApricots
107.73397208999DriedApricots
113.0400719671FreshApricots
123.087137817FreshApricots
131.4742760156Packed in juiceApricots
141.64748926094Packed in juiceApricots
151.55204253208Packed in syrup, syrup discardedApricots
161.8552908088Packed in syrup, syrup discardedApricots
173.3174627313CannedArtichoke
183.38561047493CannedArtichoke
192.21305047929FreshArtichoke
202.3637333814FreshArtichoke
215.7683252728FrozenArtichoke
226.22141832776FrozenArtichoke
232.5802971683CannedAsparagus
242.7200086787CannedAsparagus
253.0756105724FreshAsparagus
263.21349409304FreshAsparagus
275.85731991397FrozenAsparagus
286.0657860935FrozenAsparagus
292.225544076FreshAvocado
302.23587438158FreshAvocado
310.5494172928FreshBananas
320.566983414531FreshBananas
330.9427311158CannedBeets
341.01727546324CannedBeets
353.41021478336FrozenBerries, mixed
363.63694066FrozenBerries, mixed
370.945681045CannedBlack beans
380.980579717755CannedBlack beans
391.4038762924DriedBlack beans
401.48978420263DriedBlack beans
415.661671336FreshBlackberries
425.77470825035FreshBlackberries
433.38850085426FrozenBlackberries
443.6920108696FrozenBlackberries
450.910440813422CannedBlackeye peas
460.9310398825CannedBlackeye peas
471.58990085218DriedBlackeye peas
481.613022434DriedBlackeye peas
494.3911083709FreshBlueberries
504.73462168973FreshBlueberries
513.471925452FrozenBlueberries
523.64325041591FrozenBlueberries
532.3624557989FloretsBroccoli
542.56847143403FloretsBroccoli
551.8227837671FrozenBroccoli
561.86970036313FrozenBroccoli
571.63609690647HeadsBroccoli
581.9191171292HeadsBroccoli
592.76355337151FreshBrussels sprouts
602.9620929796FreshBrussels sprouts
612.0397358015FrozenBrussels sprouts
622.13825366618FrozenBrussels sprouts
631.24473670387FreshButternut squash
641.2920110231FreshButternut squash
650.579208394258Fresh green cabbageCabbage
660.6238712291Fresh green cabbageCabbage
671.0241250285Fresh red cabbageCabbage
681.05644972791Fresh red cabbageCabbage
691.153095782SauerkrautCabbage
701.26463509211SauerkrautCabbage
710.520793672FreshCantaloupe
720.535873776106FreshCantaloupe
730.9231914223CannedCarrots
741.06049032785CannedCarrots
750.741539992379Cooked wholeCarrots
760.7737514155Cooked wholeCarrots
771.3965860252FrozenCarrots
781.46051272856FrozenCarrots
791.4373172338Raw babyCarrots
801.44745804876Raw babyCarrots
810.741539992379Raw wholeCarrots
820.7737514155Raw wholeCarrots
833.1279734694FloretsCauliflower
843.27064843515FloretsCauliflower
851.6814349408FrozenCauliflower
861.716444729FrozenCauliflower
871.22881085623HeadsCauliflower
881.416972077HeadsCauliflower
892.1340528999SticksCelery
902.2049694293SticksCelery
911.0928457916Trimmed bunchesCelery
921.11365395418Trimmed bunchesCelery
933.51874337733Canned, packed in syrup or waterCherries
943.7259182628Canned, packed in syrup or waterCherries
953.2130681107FreshCherries
963.59298975549FreshCherries
970.8534190293CannedCollard greens
980.902593822572CannedCollard greens
992.6294683753FreshCollard greens
1002.63083790515FreshCollard greens
Rows: 1-100 of 314 | Columns: 3
In [55]:
market["Form"].nunique(approx = True)
Out[55]:
37.0
In [97]:
market["Form"].nunique(approx = False)
Out[97]:
37.0

See Also

vDataFrame.aggregate Computes the vDataFrame input aggregations.