Column Operations#

raphtory.nullmodels.shuffle_column(graph_df: DataFrame, col_number=None, col_name=None, inplace=False)[source]#

Returns an edgelist with a given column shuffled. Exactly one of col_number or col_name should be specified.

Parameters:
  • graph_df (pd.DataFrame) – The input DataFrame representing the timestamped edgelist.

  • col_number (int, optional) – The column number to shuffle. Default is None.

  • col_name (str, optional) – The column name to shuffle. Default is None.

  • inplace (bool, optional) – If True, shuffles the column in-place. Otherwise, creates a copy of the DataFrame. Default is False.

Returns:

The shuffled DataFrame with the specified column.

Return type:

pd.DataFrame

Raises:
  • AssertionError – If neither col_number nor col_name is provided.

  • AssertionError – If both col_number and col_name are provided.

raphtory.nullmodels.shuffle_multiple_columns(graph_df: DataFrame, col_numbers: list | None = None, col_names: list | None = None, inplace=False)[source]#

Returns an edgelist with given columns shuffled. Exactly one of col_numbers or col_names should be specified.

Parameters:
  • graph_df (pd.DataFrame) – The input DataFrame representing the graph.

  • col_numbers (list, optional) – The list of column numbers to shuffle. Default is None.

  • col_names (list, optional) – The list of column names to shuffle. Default is None.

  • inplace (bool, optional) – If True, shuffles the columns in-place. Otherwise, creates a copy of the DataFrame. Default is False.

Returns:

The shuffled DataFrame with the specified columns.

Return type:

pd.DataFrame

Raises:
  • AssertionError – If neither col_numbers nor col_names are provided.

  • AssertionError – If both col_numbers and col_names are provided.