skbio.util.cardinal_to_ordinal

skbio.util.cardinal_to_ordinal(n)[source]

Return ordinal string version of cardinal int n.

State: Experimental as of 0.4.0.

Parameters

n (int) – Cardinal to convert to ordinal. Must be >= 0.

Returns

Ordinal version of cardinal n.

Return type

str

Raises

ValueError – If n is less than 0.

Notes

This function can be useful when writing human-readable error messages.

Examples

>>> from skbio.util import cardinal_to_ordinal
>>> cardinal_to_ordinal(0)
'0th'
>>> cardinal_to_ordinal(1)
'1st'
>>> cardinal_to_ordinal(2)
'2nd'
>>> cardinal_to_ordinal(3)
'3rd'