Simplify byte column selection in correlation calculation
This commit is contained in:
@@ -27,8 +27,7 @@ def _ensure_int_bytes(df: pd.DataFrame, cols: list) -> pd.DataFrame:
|
||||
return df
|
||||
|
||||
def calculate_correlation(df: pd.DataFrame, method: str, target_id: str | None = None) -> pd.DataFrame:
|
||||
byte_cols = [f"b{i}" for i in range(8) if f"b{i}" in df.columns]
|
||||
available_cols = [col for col in byte_cols if col in df.columns]
|
||||
available_cols = [f"b{i}" for i in range(8) if f"b{i}" in df.columns]
|
||||
|
||||
if not available_cols:
|
||||
raise ValueError("No byte columns (b0-b7) found in the DataFrame")
|
||||
|
||||
+1
-2
@@ -36,8 +36,7 @@ def _entropy_col(a: np.ndarray) -> float:
|
||||
return float(-np.sum(p * np.log2(p)))
|
||||
|
||||
def calculate_byte_entropy(df: pd.DataFrame) -> pd.DataFrame:
|
||||
byte_cols = [f"b{i}" for i in range(8) if f"b{i}" in df.columns]
|
||||
available_cols = byte_cols
|
||||
available_cols = [f"b{i}" for i in range(8) if f"b{i}" in df.columns]
|
||||
if not available_cols:
|
||||
raise ValueError("No byte columns (b0-b7) found in the DataFrame")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user