forked from lux-org/lux
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Partial LuxSeries support for lux-org#66
- Loading branch information
Showing
3 changed files
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import pandas as pd | ||
class LuxSeries(pd.Series): | ||
# _metadata = ['name','_intent','data_type_lookup','data_type', | ||
# 'data_model_lookup','data_model','unique_values','cardinality', | ||
# 'min_max','plot_config', '_current_vis','_widget', '_recommendation'] | ||
def __init__(self,*args, **kw): | ||
super(LuxSeries, self).__init__(*args, **kw) | ||
@property | ||
def _constructor(self): | ||
return LuxSeries | ||
|
||
@property | ||
def _constructor_expanddim(self): | ||
from lux.core.frame import LuxDataFrame | ||
# def f(*args, **kwargs): | ||
# # adapted from https://github.com/pandas-dev/pandas/issues/13208#issuecomment-326556232 | ||
# return LuxDataFrame(*args, **kwargs).__finalize__(self, method='inherit') | ||
# return f | ||
return LuxDataFrame |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from .context import lux | ||
import pytest | ||
import pandas as pd | ||
|
||
# def test_df_to_series(): | ||
# # Ensure metadata is kept when going from df to series | ||
# df = pd.read_csv("lux/data/car.csv") | ||
# df._repr_html_() # compute metadata | ||
# assert df.cardinality is not None | ||
# series = df["Weight"] | ||
# assert isinstance(series,lux.core.series.LuxSeries), "Derived series is type LuxSeries." | ||
# assert df["Weight"]._metadata == ['name','_intent', 'data_type_lookup', 'data_type', 'data_model_lookup', 'data_model', 'unique_values', 'cardinality', 'min_max', 'plot_config', '_current_vis', '_widget', '_recommendation'], "Metadata is lost when going from Dataframe to Series." | ||
# assert df.cardinality is not None, "Metadata is lost when going from Dataframe to Series." | ||
# assert series.name == "Weight", "Pandas Series original `name` property not retained." |