Data utils#
data tools
- lsst.cst.data.ids_to_str(data_ids)#
- Transform a numpy array of ids (long int)
to a comma-separated values string
- Parameters:
data_ids (
numpy.ndarray) – numpy array with objects id- Returns:
result – String with separated by comma-separated values from the data_ids
- Return type:
- lsst.cst.data.shuffle_dataframe(df, random_state=0)#
Return a copy of the dataframe df shuffled, random_state argument may be used to reproduce same shuffling.
- Parameters:
df (
pandas.DataFrame) – dataframe to be shuffledrandom_state (
int) – number to reproduce same randomness
- Returns:
result – shuffled dataframe
- Return type:
- lsst.cst.data.sort_dataframe(df, sort_key, ascending=False, set_index=True)#
Return a sorted copy of the dataframe ‘df’ by index, selecting the desired order (ascending or descending) using the ascending argument, it also exchanges the index of the dataframe for the sort_key if set_index parameter is True (default).
- Parameters:
df (
pandas.DataFrame) – dataframe to be sortedsort_key (
str) – column key used to sort the dataframeascending (
bool, optional) – ascending/descending sortingset_index (
bool, optional) – set sorted key as the dataframe index
- Returns:
result – Copy of the
DataFramesorted using the selected column.- Return type: