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

Fixes issue where value_counts was not returning LuxSeries #210

Merged
merged 7 commits into from
Jan 9, 2021
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
1 change: 0 additions & 1 deletion lux/action/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ def register_default_actions():
from lux.action.filter import add_filter
from lux.action.generalize import generalize

print("Register default actions")
# display conditions for default actions
no_vis = lambda ldf: (ldf.current_vis is None) or (
ldf.current_vis is not None and len(ldf.current_vis) == 0
Expand Down
2 changes: 1 addition & 1 deletion lux/core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def setOption(overridePandas=True):
) = (
pd.io.spss.DataFrame
) = pd.io.stata.DataFrame = pd.io.api.DataFrame = pd.core.frame.DataFrame = LuxDataFrame
pd.Series = LuxSeries
pd.Series = pd.core.series.Series = LuxSeries
else:
pd.DataFrame = pd.io.parsers.DataFrame = pd.core.frame.DataFrame = originalDF
pd.Series = originalSeries
Expand Down
3 changes: 2 additions & 1 deletion lux/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ def __repr__(self):
# 1) Values of the series are of dtype objects (df.dtypes)
is_dtype_series = all(isinstance(val, np.dtype) for val in self.values)
# 2) Mixed type, often a result of a "row" acting as a series (df.iterrows, df.iloc[0])
mixed_dtype = len(set([type(val) for val in self.values])) > 1
# Tolerant for NaNs + 1 type
mixed_dtype = len(set([type(val) for val in self.values])) > 2
if ldf._pandas_only or is_dtype_series or mixed_dtype:
print(series_repr)
ldf._pandas_only = False
Expand Down
2 changes: 1 addition & 1 deletion tests/test_pandas_coverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ def test_value_counts(global_var):
assert df.cardinality is not None
series = df["Weight"]
series.value_counts()
assert isinstance(series, lux.core.series.LuxSeries), "Derived series is type LuxSeries."
assert type(df["Brand"].value_counts()) == lux.core.series.LuxSeries
assert df["Weight"]._metadata == [
"_intent",
"data_type",
Expand Down