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:

str

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 shuffled

  • random_state (int) – number to reproduce same randomness

Returns:

result – shuffled dataframe

Return type:

pandas.DataFrame

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 sorted

  • sort_key (str) – column key used to sort the dataframe

  • ascending (bool, optional) – ascending/descending sorting

  • set_index (bool, optional) – set sorted key as the dataframe index

Returns:

result – Copy of the DataFrame sorted using the selected column.

Return type:

pandas.DataFrame