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_homogeneous_type

Whether the object has a single dtype. By definition, Series and Index are always considered homogeneous. …

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

array

The ExtensionArray of the data backing this Series or Index.

asobject

Return object Series which contains boxed values.

at

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

axes

Return a list of the row axis labels.

base

Return the base object if the memory of the underlying data is shared.

blocks

Internal property, property synonym for as_blocks().

data

Return the data pointer of the underlying data.

dtype

Returns @see cl WeightedSeriesDtype.

dtype

Return the dtype object of the underlying data.

dtypes

Return the dtype object of the underlying data.

empty

flags

Return the ndarray.flags for the underlying data.

ftype

Return if the data is sparse|dense.

ftypes

Return if the data is sparse|dense.

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 (from …

imag

Return imag value of vector.

is_copy

Return the copy.

is_monotonic

Return boolean if values in the object are monotonic_increasing.

is_monotonic_decreasing

Return boolean if values in the object are monotonic_decreasing.

is_monotonic_increasing

Return boolean if values in the object are monotonic_increasing.

is_unique

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

itemsize

Return the size of the dtype of the item of the underlying data.

itemsize

The element size of this data-type object.

ix

A primarily label-location based indexer, with integer position fallback. Warning: Starting in 0.20.0, the .ix …

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 also …

name

Return name of the Series.

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.

real

Return the real value of vector.

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.

strides

Return the strides of 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)[source]

Concatenate multiple array

Parameters

to_concat (sequence of this type) –

Returns

Return type

@see cl WeightedArray

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.

value

Returns the values.

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.

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

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

name

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

type

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