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

_constructor

_constructor_expanddim

_constructor_sliced

Used when a manipulation result has one lower dimension(s) as the original, such as DataFrame single columns slicing. …

_info_axis

_is_boolean

_is_cached

Return boolean indicating if self is cached or not.

_is_datelike_mixed_type

_is_mixed_type

_is_numeric

_is_numeric_mixed_type

_is_view

Return boolean indicating if self is view of another array

_ndarray_values

Internal pandas method for lossy conversion to a NumPy ndarray. This method is not part of the pandas interface. …

_ndarray_values

The data as an ndarray, possibly losing information. The expectation is that this is cheap to compute, and is primarily …

_obj_with_exclusions

internal compat with SelectionMixin

_selected_obj

internal compat with SelectionMixin

_selection_list

_selection_name

return a name for myself; this would ideally be called the ‘name’ property, but we cannot conflict with the …

_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.

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 on this object.

axes

Return a list of the row axis labels.

dtype

Returns @see cl WeightedSeriesDtype.

dtype

Return the dtype object of the underlying data.

dtypes

Return the dtype object of the underlying data.

empty

hasnans

Return if I have any nans; enables various perf speedups.

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

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

is_monotonic_decreasing

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

is_monotonic_increasing

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

is_unique

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

itemsize

The element size of this data-type object.

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

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

nbytes

Return the number of bytes in the underlying data.

ndim

Extension Arrays are only allowed to be 1-dimensional.

ndim

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

numpy_dtype

The NumPy dtype this PandasDtype wraps.

shape

Return a tuple of the array dimensions.

shape

Return a tuple of the shape of the underlying data.

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 …

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.

__init__

Initializes dtype.

__len__

__mul__

Multiplication

__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)[source]

Bases: pandas.core.arrays.numpy_.PandasArray

Implements an array holding @see WeightedDouble numbers. This leverages a new concept introduced in pandas 0.24 implemented in class :epkg:`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.

__add__(other)[source]

Addition

__init__(*args, **kwargs)[source]

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

__mul__(other)[source]

Multiplication

__sub__(other)[source]

Soustraction

__truediv__(other)[source]

Division

classmethod _concat_same_type(to_concat: Sequence[ExtensionArray]) → ExtensionArray[source]

Concatenate multiple array

Parameters

to_concat (sequence of this type) –

Returns

Return type

@see cl WeightedArray

_ndarray = None
property dtype

Returns @see cl WeightedSeriesDtype.

isna()[source]

is nan?

class cpyquickhelper.numbers.weighted_dataframe.WeightedDoubleAccessor(obj)[source]

Bases: object

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

__init__(obj)[source]

Initialize self. See help(type(self)) for accurate signature.

__len__()[source]
_new_series(fct)[source]
isnan()[source]

Tells if values are missing.

property value

Returns the values.

property weight

Returns the weights.

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

Bases: pandas.core.series.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)[source]

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

__init__(*args, **kwargs)[source]

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

_data = None
_name = None
class cpyquickhelper.numbers.weighted_dataframe.WeightedSeriesDtype[source]

Bases: pandas.core.arrays.numpy_.PandasDtype

Defines a custom type for a @see cl WeightedSeries.

Initializes dtype.

__init__()[source]

Initializes dtype.

__str__()[source]

usual

classmethod construct_from_string(string)[source]

Attempt to construct this type from a string. :param string: :type string: str

Returns

self

Return type

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

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