Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor!: Remove utils.pair_plot function #92

Merged
merged 2 commits into from
Sep 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions edvart/report_sections/bivariate_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,7 @@ def include_column(col: str) -> bool:
if not allow_categorical:
columns_x = list(filter(include_column, columns_x))
columns_y = list(filter(include_column, columns_y))
utils.pair_plot(df, columns_x, columns_y, color_col=color_col)
sns.pairplot(df, x_vars=columns_x, y_vars=columns_y, hue=color_col)
plt.tight_layout()
plt.show()

Expand All @@ -690,9 +690,9 @@ def required_imports(self) -> List[str]:
)
]
return [
"from edvart import utils",
"from edvart.data_types import is_categorical, is_boolean",
"import matplotlib.pyplot as plt",
"import seaborn as sns",
]

def add_cells(self, cells: List[Dict[str, Any]]) -> None:
Expand Down
27 changes: 1 addition & 26 deletions edvart/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@

import os
from contextlib import contextmanager
from typing import Any, Dict, Iterable, Iterator, List, Literal, Optional, Tuple, Union
from typing import Any, Dict, Iterable, Iterator, Literal, Optional, Tuple, Union

import pandas as pd
import seaborn as sns
import statsmodels.api as sm


Expand Down Expand Up @@ -482,30 +481,6 @@ def _corr(df: pd.DataFrame, method: Literal["pearson", "kendall", "spearman"]) -
return df.corr(method=method, numeric_only=True)


def pair_plot(
df: pd.DataFrame,
columns_x: Optional[List[str]] = None,
columns_y: Optional[List[str]] = None,
color_col: Optional[str] = None,
) -> None:
"""
Plot a pairplot.

Parameters
----------
df: pd.DataFrame
DataFrame used for pairplot
columns_x: List[str], optional
List of columns to plot on the x-axis.
columns_y : List[str], optional
List of columns to plot on the y-axis.
color_col : str, optional
Name of columns according to which to color points in the pairplot and univariate
distribution plots on the diagonals.
"""
sns.pairplot(df, x_vars=columns_x, y_vars=columns_y, hue=color_col)


def contingency_table(df: pd.DataFrame) -> pd.DataFrame:
"""
Return contingency table.
Expand Down