- spac.data_utils.calculate_centroid(data, x_min, x_max, y_min, y_max, new_x, new_y)[source]
Calculate the spatial coordinates of the cell centroid as the average of min and max coordinates.
- Parameters:
data (pd.DataFrame) – The input data frame. The dataframe should contain four columns for x_min, x_max, y_min, and y_max for centroid calculation.
x_min (str) – column name with minimum x value
x_max (str) – column name with maximum x value
y_min (str) – column name with minimum y value
y_max (str) – column name with maximum y value
new_x (str) – the new column name of the x dimension of the cientroid, allowing characters are alphabetic, digits and underscore
new_y (str) – the new column name of the y dimension of the centroid, allowing characters are alphabetic, digits and underscore
- Returns:
data – dataframe with two new centroid columns addded. Note that the dataframe is modified in place.
- Return type:
pd.DataFrame