Skip to content

Commit

Permalink
Fix for data columns with a single value
Browse files Browse the repository at this point in the history
  • Loading branch information
fbdesignpro committed Oct 14, 2020
1 parent 05e06b7 commit 5b66f5b
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions sweetviz/series_analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,15 @@
def get_counts(series: pd.Series) -> dict:
# The value_counts() function is used to get a Series containing counts of unique values.
value_counts_with_nan = series.value_counts(dropna=False)
value_counts_without_nan = (
value_counts_with_nan.reset_index().dropna().set_index("index").iloc[:, 0]
)

# Fix for data with only a single value; reset_index was flipping the data returned
if len(value_counts_with_nan) == 1:
if pd.isna(value_counts_with_nan.index[0]):
value_counts_without_nan = pd.Series()
else:
value_counts_without_nan = value_counts_with_nan
else:
value_counts_without_nan = (value_counts_with_nan.reset_index().dropna().set_index("index").iloc[:, 0])
# print(value_counts_without_nan.index.dtype.name)

# IGNORING NAN FOR NOW AS IT CAUSES ISSUES [FIX]
Expand Down

0 comments on commit 5b66f5b

Please sign in to comment.