API Reference

si_unit_pandas.base

Base functionality.

Classes:

NumPyBackedExtensionArrayMixin()

Mixin for pandas extension backed by a numpy array.

class NumPyBackedExtensionArrayMixin[source]

Bases: ExtensionArray

Mixin for pandas extension backed by a numpy array.

Methods:

__len__()

Returns the length of this array.

argsort([ascending, kind])

Return the indices that would sort this array.

copy([deep])

Return a copy of the array.

setitem(indexer, value)

Set the 'value' inplace.

tolist()

Convert the array to a Python list.

unique()

Compute the ExtensionArray of unique values.

Attributes:

dtype

The dtype for this extension array, CelsiusType.

nbytes

The number of bytes needed to store this object in memory.

shape

Return a tuple of the array dimensions.

__len__()[source]

Returns the length of this array.

Return type

int

argsort(ascending=True, kind='quicksort', *args, **kwargs)[source]

Return the indices that would sort this array.

Parameters
  • ascending (bool) – Whether the indices should result in an ascending or descending sort. Default True.

  • kind (Union[Literal['quicksort'], Literal['mergesort'], Literal['heapsort']]) – {‘quicksort’, ‘mergesort’, ‘heapsort’}, optional Sorting algorithm. Default 'quicksort'.

*args and **kwargs are passed through to numpy.argsort().

Return type

ndarray

Returns

Array of indices that sort self. If NaN values are contained, NaN values are placed at the end.

See also

numpy.argsort: Sorting implementation used internally.

copy(deep=False)[source]

Return a copy of the array.

Parameters

deep (bool) – Default False.

Returns

Return type

ABCExtensionArray

property dtype

The dtype for this extension array, CelsiusType.

Return type

Type[ExtensionDtype]

property nbytes

The number of bytes needed to store this object in memory.

Return type

int

setitem(indexer, value)[source]

Set the ‘value’ inplace.

Return type

NumPyBackedExtensionArrayMixin

property shape

Return a tuple of the array dimensions.

Return type

Tuple[int]

tolist()[source]

Convert the array to a Python list.

Return type

List

unique()[source]

Compute the ExtensionArray of unique values.

Returns

uniques : ExtensionArray

rtype

ExtensionArray

si_unit_pandas.temperature

Temperature-specific functionality.

Classes:

Celsius(value)

float subclass representing a temperature in Celsius.

CelsiusType()

Numpy dtype representing a temperature in degrees Celsius.

Fahrenheit([value])

float subclass representing a temperature in Fahrenheit.

TemperatureArray(data[, dtype, copy])

Holder for Temperatures.

TemperatureBase()

Metaclass providing a common base class for Temperatures.

Functions:

is_temperature_type(obj)

Returns whether obj is a temperature type.

to_temperature(values)

Convert values to a TemperatureArray.

class Celsius(value)[source]

Bases: UserFloat

float subclass representing a temperature in Celsius.

Convert a string or number to a floating point number, if possible.

Methods:

__repr__()

Return a string representation of the temperature.

__str__()

Return the temperature as a string.

__repr__()[source]

Return a string representation of the temperature.

Return type

str

__str__()[source]

Return the temperature as a string.

Return type

str

class CelsiusType[source]

Bases: ExtensionDtype

Numpy dtype representing a temperature in degrees Celsius.

Methods:

construct_array_type()

Return the array type associated with this dtype.

construct_from_string(string)

Construct a CelsiusType from a string.

Classes:

type

alias of TemperatureBase

classmethod construct_array_type()[source]

Return the array type associated with this dtype.

Returns

type

rtype

Type[TemperatureArray]

classmethod construct_from_string(string)[source]

Construct a CelsiusType from a string.

Parameters

string (str)

Return type

CelsiusType

type

alias of TemperatureBase

class Fahrenheit(value=0.0)[source]

Bases: UserFloat

float subclass representing a temperature in Fahrenheit.

Convert a string or number to a floating point number, if possible.

Methods:

__repr__()

Return a string representation of the temperature.

__str__()

Return the temperature as a string.

__repr__()[source]

Return a string representation of the temperature.

Return type

str

__str__()[source]

Return the temperature as a string.

Return type

str

class TemperatureArray(data, dtype=None, copy=False)[source]

Bases: BaseArray

Holder for Temperatures.

TemperatureArray is a container for Temperatures. It satisfies pandas’ extension array interface, and so can be stored inside pandas.Series and pandas.DataFrame.

Methods:

__getitem__(item)

Select a subset of self.

append(value)

Append a value to this TemperatureArray.

astype(dtype[, copy])

Returns the array with its values as the given dtype.

isin(other)

Check whether elements of self are in other.

__getitem__(item)[source]

Select a subset of self.

Parameters

item (Union[int, slice, ndarray]) –

  • int: The position in ‘self’ to get.

  • slice: A slice object, where ‘start’, ‘stop’, and ‘step’ are integers or None.

  • ndarray: A 1-d boolean NumPy ndarray the same length as ‘self’

Return type

scalar or ExtensionArray

Note

For scalar item, return a scalar value suitable for the array’s type. This should be an instance of self.dtype.type.

For slice key, return an instance of ExtensionArray, even if the slice is length 0 or 1.

For a boolean mask, return an instance of ExtensionArray, filtered to the values where item is True.

append(value)[source]

Append a value to this TemperatureArray.

Parameters

value (Union[float, str, Sequence[Union[float, str, Celsius]]])

astype(dtype, copy=True)[source]

Returns the array with its values as the given dtype.

Parameters
  • dtype (Type)

  • copy (bool) – If True, returns a copy of the array. Default True.

isin(other)[source]

Check whether elements of self are in other.

Comparison is done elementwise.

Parameters

other (Union[float, str, Sequence[Union[float, str, Celsius]]])

Return type

ndarray

Returns

A 1-D boolean ndarray with the same length as self.

class TemperatureBase[source]

Bases: object

Metaclass providing a common base class for Temperatures.

is_temperature_type(obj)[source]

Returns whether obj is a temperature type.

Parameters

obj (Any)

Return type

bool

to_temperature(values)[source]

Convert values to a TemperatureArray.

Parameters

values (Union[float, str, Sequence[Union[float, str, Celsius]]])

Return type

TemperatureArray