nullmodels
#
Generate randomised reference models for a temporal graph edgelist
Functions#
shuffle_column(graph_df, col_number=None, col_name=None, inplace=False)
#
Returns an edgelist with a given column shuffled. Exactly one of col_number or col_name should be specified.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
graph_df
|
DataFrame
|
The input DataFrame representing the timestamped edgelist. |
required |
col_number
|
int
|
The column number to shuffle. Default is None. |
None
|
col_name
|
str
|
The column name to shuffle. Default is None. |
None
|
inplace
|
bool
|
If True, shuffles the column in-place. Otherwise, creates a copy of the DataFrame. Default is False. |
False
|
Returns:
Type | Description |
---|---|
DataFrame
|
The shuffled DataFrame with the specified column. |
Raises:
Type | Description |
---|---|
AssertionError
|
If neither col_number nor col_name is provided. |
AssertionError
|
If both col_number and col_name are provided. |
shuffle_multiple_columns(graph_df, col_numbers=None, col_names=None, inplace=False)
#
Returns an edgelist with given columns shuffled. Exactly one of col_numbers or col_names should be specified.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
graph_df
|
DataFrame
|
The input DataFrame representing the graph. |
required |
col_numbers
|
list
|
The list of column numbers to shuffle. Default is None. |
None
|
col_names
|
list
|
The list of column names to shuffle. Default is None. |
None
|
inplace
|
bool
|
If True, shuffles the columns in-place. Otherwise, creates a copy of the DataFrame. Default is False. |
False
|
Returns:
Type | Description |
---|---|
DataFrame
|
The shuffled DataFrame with the specified columns. |
Raises:
Type | Description |
---|---|
AssertionError
|
If neither col_numbers nor col_names are provided. |
AssertionError
|
If both col_numbers and col_names are provided. |
permuted_timestamps_model(graph_df, time_col=None, time_name=None, inplace=False, sorted=False)
#
Returns a DataFrame with the time column shuffled.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
graph_df
|
DataFrame
|
The input DataFrame representing the graph. |
required |
time_col
|
int
|
The column number of the time column to shuffle. Default is None. |
None
|
time_name
|
str
|
The column name of the time column to shuffle. Default is None. |
None
|
inplace
|
bool
|
If True, shuffles the time column in-place. Otherwise, creates a copy of the DataFrame. Default is False. |
False
|
sorted
|
bool
|
If True, sorts the DataFrame by the shuffled time column. Default is False. |
False
|
Returns:
Type | Description |
---|---|
DataFrame | None
|
The shuffled DataFrame with the time column, or None if inplace=True. |