reVReports.characterizations.unpack_characterizations#
- unpack_characterizations(in_df, characterization_remapper, cell_size_m=90)[source]#
Unpack characterization data from the input supply curve
This function unpacks characterization data from the input supply curve dataframe according to the specifications in
characterization_remapper, including converting values from embedded JSON strings to new standalone columns.- Parameters:
in_df (
pandas.DataFrame) – Dataframe to be unpacked. Typically, this is a DataFrame loaded from a reV supply curve CSV file.characterization_remapper (
dict) –This dictionary defines how to unpack and recast values from the characterization JSON strings to new columns.
Each top-level key in this dictionary should be the name of a column of
in_dfcontaining characterization JSON data. Only the columns you want to unpack need to be included.The corresponding value should be a dictionary with the following keys: “method”, “recast”, and “lkup” OR “rename”. Details for each are provided below:
- ”method”: Must be one of “category”, “sum”, “mean”, or
None. Note: These correspond to the “method” used for the corresponding layer in the “data_layers” input to reV supply-curve aggregation configuration.
- ”recast”: Must be one of “area” or None. This defines how
values in the JSON will be recast to new columns. If “area” is specified, they will be converted to area values. If null, they will not be changed and will be passed through as-is.
- ”lkup”: This is a dictionary for remapping categories to
new column names (see documentation of recast_categories() for more information). It should be used when “method” = “category”. It can also be specified as null to skip unpacking of the column.
- ”rename”: This is a string indicating what name to use for
the new column. This should be used when “method” != “category”.
A valid example for this parameter can be loaded from
tests/data/characterization-map.json.cell_size_m (
int, default90) – Optional cell size of the characterization layers used in reV. Default is the current standard value of 90m.
- Returns:
pandas.DataFrame– New pandas dataframe with additional columns for data unpacked from characterization columns.