module numbers.weighted_dataframe

Inheritance diagram of cpyquickhelper.numbers.weighted_dataframe

Short summary

module cpyquickhelper.numbers.weighted_dataframe

Addition for pandas.

source on GitHub

Classes

class

truncated documentation

WeightedArray

Implements an array holding @see WeightedDouble numbers. This leverages a new concept introduced in pandas 0.24 …

WeightedDoubleAccessor

Extends pandas with new accessor for series based on @see cl WeightedDouble.

WeightedSeries

Implements a series holding @see WeightedDouble numbers. Does not add anything to Series.

WeightedSeriesDtype

Defines a custom type for a @see cl WeightedSeries.

Properties

property

truncated documentation

_can_hold_na

_can_hold_na

Can arrays of this dtype hold NA values?

_constructor

_constructor_expanddim

Used when a manipulation result has one higher dimension as the original, such as Series.to_frame()

_data

_hasna

Equivalent to self.isna().any(). Some ExtensionArray subclasses may be able to optimize this check.

_info_axis

_is_boolean

Whether this dtype should be considered boolean. By default, ExtensionDtypes are assumed to be non-numeric. …

_is_cached

Return boolean indicating if self is cached or not.

_is_mixed_type

_is_numeric

Whether columns with this dtype should be considered numeric. By default ExtensionDtypes are assumed to be non-numeric. …

_is_view

Return boolean indicating if self is view of another array

_references

_stat_axis

_values

Return the internal repr of this data (defined by Block.interval_values). This are the values as stored in the Block …

array

The ExtensionArray of the data backing this Series or Index. Returns ——- ExtensionArray An ExtensionArray of the …

at

Access a single value for a row/column label pair. Similar to loc, in that both provide label-based lookups. …

attrs

Dictionary of global attributes of this dataset.

axes

Return a list of the row axis labels.

dtype

Returns @see cl WeightedSeriesDtype.

dtype

Return the dtype object of the underlying data. Examples ——– >>> s = pd.Series([1, 2, 3]) …

dtypes

Return the dtype object of the underlying data. Examples ——– >>> s = pd.Series([1, 2, 3]) …

empty

flags

Get the properties associated with this pandas object. The available flags are

hasnans

Return True if there are any NaNs. Enables various performance speedups. Returns ——- …

iat

Access a single value for a row/column pair by integer position. Similar to iloc, in that both provide integer-based …

iloc

Purely integer-location based indexing for selection by position. .iloc[] is primarily integer position based …

is_monotonic_decreasing

Return boolean if values in the object are monotonically decreasing. Returns ——- bool

is_monotonic_increasing

Return boolean if values in the object are monotonically increasing. Returns ——- bool

is_unique

Return boolean if values in the object are unique. Returns ——- bool

kind

A character code (one of ‘biufcmMOSUV’), default ‘O’ This should match the NumPy dtype used when the array is …

loc

Access a group of rows and columns by label(s) or a boolean array. .loc[] is primarily label based, but may …

na_value

Default NA value to use for this type. This is used in e.g. ExtensionArray.take. This should be the user-facing …

name

A string identifying the data type. Will be used for display in, e.g. Series.dtype

name

Return the name of the Series. The name of a Series becomes its index or column name if it is used to form …

name

A string identifying the data type. Will be used for display in, e.g. Series.dtype

names

Ordered list of field names, or None if there are no fields. This is for compatibility with NumPy arrays, and may …

nbytes

Return the number of bytes in the underlying data.

ndim

Number of dimensions of the underlying data, by definition 1.

shape

Return a tuple of the shape of the underlying data. Examples ——– >>> s = pd.Series([1, 2, …

size

Return the number of elements in the underlying data.

T

Return the transpose, which is by definition self.

type

The scalar type for the array, e.g. int It’s expected ExtensionArray[item] returns an instance of …

value

Returns the values.

values

Return Series as ndarray or ndarray-like depending on the dtype.

weight

Returns the weights.

Static Methods

staticmethod

truncated documentation

_concat_same_type

Concatenate multiple array Parameters ———- to_concat : sequence of this type Returns …

_from_sequence

construct_array_type

Return the array type associated with this dtype. Returns ——- type

construct_from_string

Attempt to construct this type from a string. Parameters ———- string : str Returns …

Methods

method

truncated documentation

__add__

Addition

__getattr__

Tries first to see if class Series has this attribute and then tries @see cl WeightedDoubleAccessor.

__init__

Overwrites the constructor to force dtype to be @see cl WeightedSeriesDtype.

__init__

__init__

Overwrites the constructor to force dtype to be @see cl WeightedSeriesDtype.

__len__

__mul__

Multiplication

__repr__

usual

__str__

usual

__sub__

Soustraction

__truediv__

Division

_new_series

isna

is nan?

isnan

Tells if values are missing.

Documentation

@file @brief Addition for pandas.

class cpyquickhelper.numbers.weighted_dataframe.WeightedArray(*args, **kwargs)

Bases: PandasArray

Implements an array holding @see WeightedDouble numbers. This leverages a new concept introduced in pandas 0.24 implemented in class PandasArray. It can be used to define a new column type in a dataframe.

Overwrites the constructor to force dtype to be @see cl WeightedSeriesDtype.

__abstractmethods__ = frozenset({})
__add__(other)

Addition

__init__(*args, **kwargs)

Overwrites the constructor to force dtype to be @see cl WeightedSeriesDtype.

__mul__(other)

Multiplication

__sub__(other)

Soustraction

__truediv__(other)

Division

_abc_impl = <_abc._abc_data object>
classmethod _concat_same_type(to_concat: Sequence[ExtensionArrayT]) ExtensionArrayT

Concatenate multiple array

Parameters

to_concat : sequence of this type

Returns

@see cl WeightedArray

classmethod _from_sequence(scalars, *, dtype=None, copy=False)

Construct a new ExtensionArray from a sequence of scalars.

Parameters

scalarsSequence

Each element will be an instance of the scalar type for this array, cls.dtype.type or be converted into this type in this method.

dtypedtype, optional

Construct for this particular dtype. This should be a Dtype compatible with the ExtensionArray.

copybool, default False

If True, copy the underlying data.

Returns

ExtensionArray

property dtype

Returns @see cl WeightedSeriesDtype.

isna()

is nan?

property name

A string identifying the data type. Will be used for display in, e.g. Series.dtype

class cpyquickhelper.numbers.weighted_dataframe.WeightedDoubleAccessor(obj)

Bases: object

Extends pandas with new accessor for series based on @see cl WeightedDouble.

__init__(obj)
__len__()
_new_series(fct)
isnan()

Tells if values are missing.

property value

Returns the values.

property weight

Returns the weights.

class cpyquickhelper.numbers.weighted_dataframe.WeightedSeries(*args, **kwargs)

Bases: Series

Implements a series holding @see WeightedDouble numbers. Does not add anything to Series.

Overwrites the constructor to force dtype to be @see cl WeightedSeriesDtype.

__getattr__(attr)

Tries first to see if class Series has this attribute and then tries @see cl WeightedDoubleAccessor.

__init__(*args, **kwargs)

Overwrites the constructor to force dtype to be @see cl WeightedSeriesDtype.

_mgr: SingleManager
_name: Hashable
class cpyquickhelper.numbers.weighted_dataframe.WeightedSeriesDtype

Bases: ExtensionDtype

Defines a custom type for a @see cl WeightedSeries.

__repr__()

usual

__str__()

usual

classmethod construct_array_type()

Return the array type associated with this dtype.

Returns

type

classmethod construct_from_string(string)

Attempt to construct this type from a string. Parameters ———- string : str

Returns

self : instance of ‘WeightedDouble’

Raises

TypeError

If a class cannot be constructed from this ‘string’.

property kind

A character code (one of ‘biufcmMOSUV’), default ‘O’ This should match the NumPy dtype used when the array is converted to an ndarray, ‘O’ in this case. type.

See Also

numpy.dtype.kind

property name

A string identifying the data type. Will be used for display in, e.g. Series.dtype

property type: type

The scalar type for the array, e.g. int It’s expected ExtensionArray[item] returns an instance of ExtensionDtype.type for scalar item.