ineqpy.utils

Useful functions that make easier develop other functions.

Module Contents

Functions

_to_df(→ pandas.DataFrame)

_apply_to_df(func, df, x, weights, *args, **kwargs)

Generalize main arguments as Series of a pd.Dataframe.

not_empty_weights(weights, like)

Create weights.

not_null_condition(income, weights)

Filter not null condition.

_sort_values(values, partner)

_clean_nans_values(this, pair)

normalize(this)

Normalize data by the sum.

extract_values(data, variable, weights)

Extract values.

repeat_data_from_weighted(x, w)

Generate data data (not sampled) from weights.

generate_data_to_test([n_sample_range])

Generate sampled data for testing.

ineqpy.utils._to_df(*args, **kwargs) pandas.DataFrame[source]
ineqpy.utils._apply_to_df(func, df, x, weights, *args, **kwargs)[source]

Generalize main arguments as Series of a pd.Dataframe.

Parameters:
funcfunction

Function to convert his arguments in Series of an Dataframe.

dfpandas.Dataframe

DataFrame whats contains the Series x_name and w_name.

x_namestr

Name of the column in df.

weights_namestr

Name of the column in df.

Returns:
returnfunc return

It’s depends of func output type.

ineqpy.utils.not_empty_weights(weights, like)[source]

Create weights.

Create normalized weight if it’s None use like to create it.

Parameters:
income, likearray-like
Returns:
weightsarray-like

Filtered array-like.

See also

normalize
ineqpy.utils.not_null_condition(income, weights)[source]

Filter not null condition.

If a negative value is found in the incomes it will dropped.

Parameters:
income, weightsarray-like
Returns:
income, weightsarray-like

Filtered array-like.

ineqpy.utils._sort_values(values, partner)[source]
ineqpy.utils._clean_nans_values(this, pair)[source]
ineqpy.utils.normalize(this)[source]

Normalize data by the sum.

Parameters:
thisarray-like
Returns:
outarray-like
ineqpy.utils.extract_values(data, variable, weights)[source]

Extract values.

Parameters:
datapandas.DataFrame
variablestr
weightsstr
Returns:
variable, weightsarray-like
ineqpy.utils.repeat_data_from_weighted(x, w)[source]

Generate data data (not sampled) from weights.

Parameters:
x, warray-like
Returns:
repeated_x, repeated_wnp.array
ineqpy.utils.generate_data_to_test(n_sample_range=(20, 100))[source]

Generate sampled data for testing.

Parameters:
n_sample_rangetuple[int, int]

It’s a shape, lenght and columns.

Returns:
income, weightsnp.array