lontras

class lontras.DataFrame(data: Mapping[Hashable, Series] | Mapping[Hashable, Collection[int | float | complex | str | bool]] | Collection[Series] | Collection[Mapping[Hashable, int | float | complex | str | bool]] | Collection[int | float | complex | str | bool] | Collection[Collection[int | float | complex | str | bool]] | Iterator | None = None, index: Sequence[Hashable] | None = None, columns: Sequence[Hashable] | None = None)

Bases: UserDict

property T: DataFrame
abs() DataFrame

Returns the absolute values for DataFrame

Returns:

DataFrame: Absolute values DataFrame

agg(method: Callable[[Collection[Any]], Any], axis: Literal[0, 1] = 0) Series
all() Series
all(axis: Literal[0, 1]) Series
all(axis: None) bool
any() Series
any(axis: Literal[0, 1]) Series
any(axis: None) bool
apply(method: Callable[[Series], Any], axis: Literal[0, 1] = 0) Series
astype(new_type: type) DataFrame

Casts the DataFrame to a new type.

Args:

new_type (type): The type to cast to.

Returns:

DataFrame: A new DataFrame with the values cast to the new type.

columns: Sequence[Hashable]
idxmax() Series
idxmax(axis: Literal[0, 1]) Series
idxmax(axis: None) bool
idxmin() Series
idxmin(axis: Literal[0, 1]) Series
idxmin(axis: None) bool
iloc_indexer: IlocIndexer
index: Sequence[Hashable]
iterrows() Generator[tuple[Hashable, Series]]
loc_indexer: LocIndexer
map(func: Callable) DataFrame

Applies a function to each value in the DataFrame.

Args:

func (Callable): The function to apply.

Returns:

DataFrame: A new DataFrame with the results of the function applied.

max() Series
max(axis: Literal[0, 1]) Series
max(axis: None) int | float | complex | str | bool
mean(axis: Literal[0, 1]) Series
mean(axis: None) int | float | complex | str | bool

Computes the mean of the Series.

Returns:

float: Series mean

median(axis: Literal[0, 1]) Series
median(axis: None) int | float | complex | str | bool

Return the median (middle value) of numeric data, using the common “mean of middle two” method. If data is empty, StatisticsError is raised. data can be a sequence or iterable.

Returns:

float | int: Series median

min() Series
min(axis: Literal[0, 1]) Series
min(axis: None) int | float | complex | str | bool
mode(axis: Literal[0, 1] = 0) Series

Return the single most common data point from discrete or nominal data. The mode (when it exists) is the most typical value and serves as a measure of central location.

Returns:

Any: Series mode

name
op(op: str, other: DataFrame | Series | Mapping | Collection | int | float | complex | str | bool) DataFrame
quantiles(*, n=4, method: Literal['exclusive', 'inclusive'] = 'exclusive', axis: Literal[0, 1] = 0) Series

Divide data into n continuous intervals with equal probability. Returns a list of n - 1 cut points separating the intervals.

Returns:

list[float]: List containing quantiles

property shape: tuple[int, int]
std(xbar, axis: Literal[0, 1]) Series
std(xbar, axis: None) int | float | complex | str | bool

Return the sample standard deviation (the square root of the sample variance). See variance() for arguments and other details.

Returns:

float: Series standard deviation

sum() Series
sum(axis: Literal[0, 1]) Series
sum(axis: None) int | float | complex | str | bool
to_dict() dict[Hashable, dict[Hashable, Any]]
to_dict(orient: Literal['dict']) dict[Hashable, dict[Hashable, Any]]
to_dict(orient: Literal['list']) dict[Hashable, list[Any]]
to_dict(orient: Literal['records']) list[dict[Hashable, Any]]

Converts the DataFrame to a dictionary.

Args:
orient str {dict, list, records}: Determines the type of the values of the

dictionary.

Returns:

dict[Hashable, Any]: A dictionary representation of the Series.

to_list() list[list[Any]]

Converts the DataFrame to a list.

Returns:

list[list[Any]]: A list of the Series values.

property values: list[list[Any]]

Return a list representation of the DataFrame.

Returns:

list: The values of the DataFrame.

var(xbar, axis: Literal[0, 1]) Series
var(xbar, axis: None) int | float | complex | str | bool

Return the sample variance of data, an iterable of at least two real-valued numbers. Variance, or second moment about the mean, is a measure of the variability (spread or dispersion) of data. A large variance indicates that the data is spread out; a small variance indicates it is clustered closely around the mean.

Returns:

float: Series variance

class lontras.Series(data: Mapping | Collection | int | float | complex | str | bool | None = None, index: Sequence[Hashable] | None = None, name: Hashable = None)

Bases: UserDict

Series class representing a one-dimensional labeled array with capabilities for data analysis.

Attributes:

name (Hashable): Name of the Series. loc_indexer (LocIndexer): Indexer for label-based location selection. iloc_indexer (ilocIndexer): Indexer for integer-based location selection.

abs() Series

Returns the absolute values for Series

Returns:

Series: Absolute values Series

agg(func: Callable) Any

Applies an aggregation function to the Series’ values.

This method applies a given function to all the values in the Series. It is intended for aggregation functions that operate on a collection of values and return a single result.

Args:
func (Callable): The aggregation function to apply. This function

should accept an iterable (like a list or NumPy array) and return a single value.

Returns:

Any: The result of applying the aggregation function to the Series’ values.

all() bool

Returns True if all values in the Series are True.

Returns:

bool: True if all values are True, False otherwise.

any() bool

Returns True if any value in the Series is True.

Returns:

bool: True if any value is True, False otherwise.

argmax() int

Returns the index of the maximum value.

Returns:

int: The index of the maximum value.

argmin() int

Returns the index of the minimum value.

Returns:

int: The index of the minimum value.

astype(new_type: type) Series

Casts the Series to a new type.

Args:

new_type (type): The type to cast to.

Returns:

Series: A new Series with the values cast to the new type.

copy(*, deep: bool = True)

Creates a copy of the Series.

Args:

deep (bool, optional): If True, creates a deep copy. Otherwise, creates a shallow copy. Defaults to True.

Returns:

Series: A copy of the Series.

dot(other: Series | Collection | int | float | complex | str | bool) int | float | complex | str | bool

Performs dot product with another Series, Collection or Scalar.

If other is a Series or a Collection, performs the dot product between the two. If other is a Scalar, multiplies all elements of the Series by the scalar and returns the sum.

Args:

other (Series | Collection | Scalar)

Returns:

Scalar: The dot product of the Series.

find(val: Any) Hashable | None

Finds the first label (key) associated with a given value in the Series.

Args:

val (Any): The value to search for.

Returns:
Hashable | None: The label (key) of the first occurrence of the value,

or None if the value is not found.

head(n: int = 5) Series

Returns the first n rows.

Args:

n (int, optional): Number of rows to return. Defaults to 5.

Returns:

Series: A new Series containing the first n rows.

idxmax() Hashable | None

Returns the label of the maximum value.

Returns:

Hashable: The label of the maximum value.

idxmin() Hashable | None

Returns the label of the minimum value.

Returns:

Hashable: The label of the minimum value.

ifind(val: Any) int | None

Finds the first integer position (index) of a given value in the Series.

Args:

val (Any): The value to search for.

Returns:
int | None: The integer position (index) of the first occurrence of the value,

or None if the value is not found.

iloc_indexer: IlocIndexer
property index: Sequence[Hashable]

Returns the index of the Series.

Returns:

Index: The index of the Series.

loc_indexer: LocIndexer
map(func: Callable) Series

Applies a function to each value in the Series.

Args:

func (Callable): The function to apply.

Returns:

Series: A new Series with the results of the function applied.

max() int | float | complex | str | bool

Returns the maximum value in the Series.

Returns:

Any: The maximum value.

mean() int | float | complex | str | bool

Computes the mean of the Series.

Returns:

float: Series mean

median() int | float | complex | str | bool

Return the median (middle value) of numeric data, using the common “mean of middle two” method. If data is empty, StatisticsError is raised. data can be a sequence or iterable.

Returns:

float | int: Series median

min() int | float | complex | str | bool

Returns the minimum value in the Series.

Returns:

Any: The minimum value.

mode() int | float | complex | str | bool

Return the single most common data point from discrete or nominal data. The mode (when it exists) is the most typical value and serves as a measure of central location.

Returns:

Any: Series mode

name: Hashable
quantiles(*, n=4, method: Literal['exclusive', 'inclusive'] = 'exclusive') Collection[float]

Divide data into n continuous intervals with equal probability. Returns a list of n - 1 cut points separating the intervals.

Returns:

list[float]: List containing quantiles

reduce(func: Callable, initial: Any)

Reduces the Series using a function.

Args:

func (Callable): The function to apply for reduction. initial (Any): The initial value for the reduction.

Returns:

Any: The reduced value.

reindex(index: Sequence[Hashable]) Series

Sets the index of the Series.

Args:

value (Index): The new index for the Series.

Raises:

ValueError: If the length of the new index does not match the length of the Series.

rename(name: Hashable) Series

Renames the Series.

Args:

name (Hashable): The new name for the Series.

Returns:

Series: A new Series with the updated name (a copy).

std(xbar=None) int | float | complex | str | bool

Return the sample standard deviation (the square root of the sample variance). See variance() for arguments and other details.

Returns:

float: Series standard deviation

sum() int | float | complex | str | bool

Returns the sum of the values in the Series.

Returns:

Any: The sum of the values.

tail(n: int = 5) Series

Returns the last n rows.

Args:

n (int, optional): Number of rows to return. Defaults to 5.

Returns:

Series: A new Series containing the last n rows.

to_dict() dict[Hashable, Any]

Converts the Series to a dictionary.

Returns:

dict[Hashable, Any]: A dictionary representation of the Series.

to_list() list[Any]

Converts the Series to a list.

Returns:

list[Any]: A list of the Series values.

property values: list[Any]

Return a list representation of the Series.

Returns:

list: The values of the Series.

var(xbar=None) int | float | complex | str | bool

Return the sample variance of data, an iterable of at least two real-valued numbers. Variance, or second moment about the mean, is a measure of the variability (spread or dispersion) of data. A large variance indicates that the data is spread out; a small variance indicates it is clustered closely around the mean.

Returns:

float: Series variance