d3m.base.utils¶
-
d3m.base.utils.
combine_columns
(inputs, column_indices, columns_list, *, return_result, add_index_columns)[source]¶ Method which appends existing columns, replaces them, or creates new result from them, based on
return_result
argument, which can beappend
,replace
, ornew
.add_index_columns
controls if when creating a new result, primary index columns should be added if they are not already among columns.inputs
is a DataFrame for which we are appending on replacing columns, or if we are creating new result, from where a primary index column can be taken.column_indices
controls which columns ininputs
were used to createcolumns_list
, and which columns should be replaced when replacing them.columns_list
is a list of DataFrames representing all together new columns. The reason it is a list is to make it easier to operate per-column when preparingcolumns_list
and not have to concat them all together unnecessarily.Top-level metadata in
columns_list
is ignored, except when creating new result. In that case top-level metadata from the first element in the list is used.When
column_indices
columns are being replaced withcolumns_list
, existing metadata incolumn_indices
columns is not preserved but replaced with metadata incolumns_list
. Ideally, metadata forcolumns_list
has been constructed by copying source metadata fromcolumn_indices
columns and modifying it as necessary to adapt it to new columns. Butcolumns_list
also can have completely new metadata, if this is more reasonable, but it should be understood that in this case when replacingcolumn_indices
columns, any custom additional metadata on those columns will be lost.column_indices
andcolumns_list
do not have to match in number of columns. Columns are first replaced in order for matching indices and columns. If then there are morecolumn_indices
thancolumns_list
, additionalcolumn_indices
columns are removed. If there are morecolumns_list
thancolumn_indices
columns, then additionalcolumns_list
are inserted after the last replaced column.If
column_indices
is empty, then the replacing behavior is equivalent to appending.- Return type
-
d3m.base.utils.
combine_columns_metadata
(inputs, column_indices, columns_list, *, return_result, add_index_columns)[source]¶ Analogous to
combine_columns
but operates only on metadata.- Return type
-
d3m.base.utils.
construct_file_uri
(location_base_uris, filename)[source]¶ Construct the file URI given
location_base_uris
values and afilename
(which should be in POSIX format). Generally,filename
comes from the column of a collection resource.- Return type
-
d3m.base.utils.
get_columns_to_use
(metadata, use_columns, exclude_columns, can_use_column)[source]¶ A helper function which computes a list of columns to use and a list of columns to ignore given
use_columns
,exclude_columns
, and acan_use_column
function which should returnTrue
when column can be used.
-
d3m.base.utils.
get_tabular_resource
(dataset, resource_id, *, pick_entry_point=True, pick_one=True, has_hyperparameter=True)[source]¶