Skip to content

Commit

Permalink
fix(eda): interaction error in report for cat-only df
Browse files Browse the repository at this point in the history
  • Loading branch information
jwa345 authored and jinglinpeng committed Feb 18, 2022
1 parent 0a3d037 commit e60239a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
9 changes: 6 additions & 3 deletions dataprep/eda/correlation/render.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,12 +385,15 @@ def render_crossfilter(
all_cols = itmdt["all_cols"]
else:
all_cols = itmdt["num_cols"]

scatter_df = itmdt["scatter_source"]
# all other plots except for scatter plot, used for cat-cat and cat-num interactions.
other_plots = itmdt["other_plots"]
scatter_df["__x__"] = scatter_df[scatter_df.columns[0]]
scatter_df["__y__"] = scatter_df[scatter_df.columns[0]]
if scatter_df.empty:
scatter_df["__x__"] = [None] * len(itmdt["scatter_source"])
scatter_df["__y__"] = [None] * len(itmdt["scatter_source"])
else:
scatter_df["__x__"] = scatter_df[scatter_df.columns[0]]
scatter_df["__y__"] = scatter_df[scatter_df.columns[0]]
source_scatter = ColumnDataSource(scatter_df)
source_xy_value = ColumnDataSource({"x": [scatter_df.columns[0]], "y": [scatter_df.columns[0]]})
var_list = list(all_cols)
Expand Down
6 changes: 6 additions & 0 deletions dataprep/tests/eda/test_create_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,9 @@ def test_dataset() -> None:

def test_random_df(random_df: pd.DataFrame) -> None:
create_report(random_df)


def test_cat_df() -> None:
df = load_dataset("titanic")
ddf = df[["Name", "Sex"]]
create_report(ddf)

0 comments on commit e60239a

Please sign in to comment.