Skip to content

Commit

Permalink
fix(eda): fixed uncaught dtype exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
eutialia committed Apr 26, 2021
1 parent 9cb11f4 commit d301eb7
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
14 changes: 14 additions & 0 deletions dataprep/eda/create_report/formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
Continuous,
DateTime,
Nominal,
GeoGraphy,
detect_dtype,
is_dtype,
)
Expand Down Expand Up @@ -127,6 +128,8 @@ def format_basic(df: dd.DataFrame, cfg: Config) -> Dict[str, Any]:
ins = _format_cont_ins(col, dat, data["ov"]["nrows"], cfg)[1]
elif is_dtype(dtp, Nominal()):
ins = _format_nom_ins(col, dat, data["ov"]["nrows"], cfg)[1]
elif is_dtype(dtp, GeoGraphy()):
ins = _format_nom_ins(col, dat, data["ov"]["nrows"], cfg)[1]
else:
continue
all_ins += ins
Expand All @@ -150,6 +153,11 @@ def format_basic(df: dd.DataFrame, cfg: Config) -> Dict[str, Any]:
stats = format_cat_stats(
data[col]["stats"], data[col]["len_stats"], data[col]["letter_stats"]
)
elif is_dtype(detect_dtype(df[col]), GeoGraphy()):
itmdt = Intermediate(col=col, data=data[col], visual_type="categorical_column")
stats = format_cat_stats(
data[col]["stats"], data[col]["len_stats"], data[col]["letter_stats"]
)
elif is_dtype(detect_dtype(df[col]), DateTime()):
itmdt = Intermediate(
col=col,
Expand Down Expand Up @@ -268,6 +276,8 @@ def basic_computations(
data[col] = nom_comps(df.frame[col], df.frame[col].head(), cfg)
elif is_dtype(detect_dtype(df.frame[col]), Nominal()):
data[col] = nom_comps(df.frame[col], first_rows[col], cfg)
elif is_dtype(detect_dtype(df.frame[col]), GeoGraphy()):
data[col] = nom_comps(df.frame[col], first_rows[col], cfg)
elif is_dtype(detect_dtype(df.frame[col]), Continuous()):
data[col] = cont_comps(df.frame[col], cfg)
elif is_dtype(detect_dtype(df.frame[col]), DateTime()):
Expand All @@ -289,6 +299,10 @@ def basic_computations(
data["insights"].append(
(col, Nominal(), _nom_calcs(df.frame[col].dropna(), head[col], cfg))
)
elif is_dtype(col_dtype, GeoGraphy()):
data["insights"].append(
(col, Nominal(), _nom_calcs(df.frame[col].dropna(), head[col], cfg))
)
elif is_dtype(col_dtype, DateTime()):
data["insights"].append(
(col, DateTime(), dask.delayed(_calc_line_dt)(df.frame[[col]], cfg.line.unit))
Expand Down
12 changes: 5 additions & 7 deletions dataprep/eda/create_report/templates/scripts.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,17 @@
for (let i of element) {
let thValue = i.firstElementChild.innerText;
let tbValue = i.lastElementChild.innerText;
if (thValue.includes('Distinct') && tbValue > 50) {
i.style.color = color;
} else if (thValue.includes('Unique') && tbValue.replace('%',
'') == 100) {
if (thValue.includes('Unique') && tbValue.replace('%',
'') == 100) {
i.style.color = color;
} else if (thValue.includes('Missing') && tbValue.replace('%',
'') != 0) {
'') != 0) {
i.style.color = color;
} else if (thValue.includes('Zeros') && tbValue.replace('%',
'') != 0) {
'') != 0) {
i.style.color = color;
} else if (thValue.includes('Infinite') && tbValue.replace('%',
'') != 0) {
'') != 0) {
i.style.color = color;
} else if (thValue.includes('Skewness' && tbValue > 20)) {
i.style.color = color;
Expand Down

0 comments on commit d301eb7

Please sign in to comment.