nuctransportdb.merge_method
Attributes
Functions
|
Filter data in the input DataFrame that is empty. |
|
Filter some data in the input DataFrame that contains invalid entries. |
|
Filter some data in the input DataFrame given by a probability distribution. |
|
Filter some data in the input DataFrame given by a range. |
|
Filter some data in the input DataFrame that can be assumed with a truncated normal distribution. |
|
Filter some data in the input DataFrame that can be assumed with a log-normal distribution. |
|
Filter some data in the input DataFrame that can be assumed with a PERT distribution. |
|
Format the number adaptively: If the number is smaller than 0.0001, use scientific notation and keep two significant digits. |
|
Generate a truncated normal distribution based on the given parameters. |
|
Generate a PERT distribution based on the given parameters. |
|
Generate a log-normal distribution based on the given parameters. |
|
Generate a uniform distribution based on the given parameters. |
|
Generate a normal distribution based on the given parameters. |
|
Generate samples for a group of input data according to its specified distribution type, including uniform, truncated normal, log-normal, and PERT. |
|
This function concatenates samples from different distributions for a group of input data and computes statistical properties (mean, std, min, max). |
|
Generate a unit string and base for a given property name. |
|
Merge property values from multiple datasets into a single DataFrame with combined statistics. The merged results include summary statistics and truncated normal distribution parameters for each property, along with metadata such as description and combined IDs. |
Module Contents
- nuctransportdb.merge_method.value_empty_mask(input_pd_df)[source]
Filter data in the input DataFrame that is empty.
- Parameters:
input_pd_df (pd.DataFrame) – Input DataFrame.
- Returns:
A Boolean series indicating which data is empty.
- Return type:
pd.Series
- nuctransportdb.merge_method.value_invalid_mask(input_pd_df)[source]
Filter some data in the input DataFrame that contains invalid entries.
- Parameters:
input_pd_df (pd.DataFrame) – Input DataFrame.
- Returns:
A Boolean Series indicating which data is invalid.
- Return type:
pd.Series
- nuctransportdb.merge_method.value_pdf_mask(input_pd_df)[source]
Filter some data in the input DataFrame given by a probability distribution.
- Parameters:
input_pd_df (pd.DataFrame) – Input DataFrame.
- Returns:
A Boolean series indicating which data entries have a corresponding probability distribution.
- Return type:
pd.Series
- nuctransportdb.merge_method.value_uniform_mask(input_pd_df)[source]
Filter some data in the input DataFrame given by a range.
- Parameters:
input_pd_df (pd.DataFrame) – Input DataFrame.
- Returns:
A Boolean series indicating which data is uniform.
- Return type:
pd.Series
- nuctransportdb.merge_method.value_truncnorm_mask(input_pd_df)[source]
Filter some data in the input DataFrame that can be assumed with a truncated normal distribution.
- Parameters:
input_pd_df (pd.DataFrame) – Input DataFrame.
- Returns:
A Boolean series indicating which data is truncated normal.
- Return type:
pd.Series
- nuctransportdb.merge_method.value_lognorm_mask(input_pd_df)[source]
Filter some data in the input DataFrame that can be assumed with a log-normal distribution.
- Parameters:
input_pd_df (pd.DataFrame) – Input DataFrame.
- Returns:
A Boolean series indicating which data is log-normal.
- Return type:
pd.Series
- nuctransportdb.merge_method.value_PERT_mask(input_pd_df)[source]
Filter some data in the input DataFrame that can be assumed with a PERT distribution.
- Parameters:
input_pd_df (pd.DataFrame) – Input DataFrame.
- Returns:
A Boolean series indicating which data is PERT.
- Return type:
pd.Series
- nuctransportdb.merge_method.format_number_adaptive(number)[source]
Format the number adaptively: If the number is smaller than 0.0001, use scientific notation and keep two significant digits. If the number is between 0.001 and 0.1, use three significant digits. Otherwise, round to two decimal places.
- nuctransportdb.merge_method.generate_truncnorm(value, value_std, value_min, value_max, as_string=False, **kwargs)[source]
Generate a truncated normal distribution based on the given parameters.
- Parameters:
value (float) – The mean of the original dataset.
value_std (float) – The standard deviation of the original dataset.
value_min (float) – The minimum value of the original dataset.
value_max (float) – The maximum value of the original dataset.
as_string (bool) – If True, return a string representation of the truncated normal distribution. If False, return a frozen distribution object. Default is False.
**kwargs – Extra keyword arguments accepted for compatibility and ignored.
- Returns:
A truncated normal distribution object if as_string is False, otherwise a string representation.
- Return type:
scipy.stats._distn_infrastructure.rv_continuous_frozen | str
- nuctransportdb.merge_method.generate_PERT(value, value_min, value_max, as_string=False, **kwargs)[source]
Generate a PERT distribution based on the given parameters.
- Parameters:
value (float) – The mean of the original dataset.
value_min (float) – The minimum value of the original dataset.
value_max (float) – The maximum value of the original dataset.
as_string (bool) – If True, return a string representation of the PERT distribution. If False, return a beta distribution object. Default is False.
**kwargs – Extra keyword arguments accepted for compatibility and ignored.
- Returns:
A beta distribution object if as_string is False, otherwise a string representation.
- Return type:
scipy.stats._distn_infrastructure.rv_continuous_frozen | str
- nuctransportdb.merge_method.generate_lognorm(value, value_std, value_min, as_string=False, **kwargs)[source]
Generate a log-normal distribution based on the given parameters.
- Parameters:
value (float) – The mean of the original dataset.
value_std (float) – The standard deviation of the original dataset.
value_min (float) – Shift the distribution to start from the minimum value.
as_string (bool) – If True, return a string representation of the log-normal distribution. If False, return a log-normal distribution object. Default is False.
**kwargs – Extra keyword arguments accepted for compatibility and ignored.
- Returns:
A log-normal distribution object if as_string is False, otherwise a string representation.
- Return type:
scipy.stats._distn_infrastructure.rv_continuous_frozen | str
- nuctransportdb.merge_method.generate_uniform(value_min, value_max, as_string=False, **kwargs)[source]
Generate a uniform distribution based on the given parameters.
- Parameters:
value_min (float) – The minimum value of the original dataset.
value_max (float) – The maximum value of the original dataset.
as_string (bool) – If True, return a string representation of the uniform distribution. If False, return a uniform distribution object. Default is False.
**kwargs – Extra keyword arguments accepted for compatibility and ignored.
- Returns:
A uniform distribution object if as_string is False, otherwise a string representation.
- Return type:
scipy.stats._distn_infrastructure.rv_continuous_frozen | str
- nuctransportdb.merge_method.generate_norm(value, value_std, as_string=False, **kwargs)[source]
Generate a normal distribution based on the given parameters.
- Parameters:
value (float) – The mean of the original dataset.
value_std (float) – The standard deviation of the original dataset.
as_string (bool) – If True, return a string representation of the normal distribution. If False, return a normal distribution object. Default is False.
**kwargs – Extra keyword arguments accepted for compatibility and ignored.
- Returns:
A normal distribution object if as_string is False, otherwise a string representation.
- Return type:
scipy.stats._distn_infrastructure.rv_continuous_frozen | str
- nuctransportdb.merge_method.generate_samples(input_df_group, df_pdf_type, random_state=21)[source]
Generate samples for a group of input data according to its specified distribution type, including uniform, truncated normal, log-normal, and PERT.
- Parameters:
input_df_group (pd.DataFrame) – The input DataFrame containing the data for one specific property and one type of pdf.
df_pdf_type (str) – The type of probability distribution function to use. It can be “is_pdf_df”, “is_uniform_df”, “is_truncnorm_df”, “is_lognorm_df”, or “is_PERT_df”.
random_state (int, optional) – The random state for reproducibility. Defaults to 21.
- Raises:
ValueError – If the distribution type is not recognized.
- Returns:
The generated samples falls within three standard deviations of the mean.
- Return type:
np.ndarray
- nuctransportdb.merge_method.get_sample_statistics(input_property_group)[source]
This function concatenates samples from different distributions for a group of input data and computes statistical properties (mean, std, min, max).
- Parameters:
input_property_group (pd.DataFrame) – DataFrame containing values for one specific property.
- Returns:
- A tuple containing the mean, standard deviation, minimum value, maximum value of the combined samples.
The tuple is in the following order: (samples_mean, samples_std, samples_min, samples_max)
- Return type:
- nuctransportdb.merge_method.generate_unit(property_name)[source]
Generate a unit string and base for a given property name.
- nuctransportdb.merge_method.merge_property_value(input_property, sample_size=1000000, source_type='merged', sampling_functions_by_property=None)[source]
Merge property values from multiple datasets into a single DataFrame with combined statistics. The merged results include summary statistics and truncated normal distribution parameters for each property, along with metadata such as description and combined IDs.
- Parameters:
input_property (pd.DataFrame) – DataFrame containing property values.
sample_size (int) – The number of samples to generate for each merged dataset. Default is 1000000.
source_type (str) – “merged” or “default”. Default is “merged”.
sampling_functions_by_property (dict) – A dictionary mapping property names to desired sampling functions. If provided, the function will use the specified sampling functions for each property instead of the truncnorm.
- Returns:
DataFrame containing merged property values, summary statistics, distribution parameters, and metadata for each property.
- Return type:
pd.DataFrame