Skip to content

Commit

Permalink
Fix issue where LuxDataFrame(df) wasn't working (#416)
Browse files Browse the repository at this point in the history
* add series equality and value counts test

* black formatting

* fix old value counts test instead

* add pandas tests

* remove str from column group

* save work on groupby bugs so far

* fix merge conflict again

* add new tests and add groupby bug fixes

* remove tests for staging

* update series tests

* add back getitem

* fix merge conflicts for staging

* remove print statements

* revert Makefile

* add test for name column case

* add test to ensure column is not all None

* re-add tests and commit new groupby implementation

* make parent LuxGroupby

* reformat LuxGroupBy and fix SeriesGroupby issue

* remove pandas tests

* run black

* finish seriesgroupby metadata propagation and add test

* run black

* fall back to normal if intent is invalid

* run black

* taking care of multiple attributes in clause case

* run black

* modified tests

* replace logic with validate_intent

* save changes

* add _testing to override Pandas

* cleanup code

* revert ipython display widget

* run black

* add test for bug fixed

* run black

Co-authored-by: Doris Lee <dorisjunglinlee@gmail.com>
  • Loading branch information
westernguy2 and dorisjlee committed Aug 31, 2021
1 parent 51d6c60 commit 4d46ad9
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lux/core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ def setOption(overridePandas=True):
pd.io.pytables.DataFrame
) = (
pd.io.spss.DataFrame
) = pd.io.stata.DataFrame = pd.io.api.DataFrame = pd.core.frame.DataFrame = LuxDataFrame
) = (
pd.io.stata.DataFrame
) = pd.io.api.DataFrame = pd.core.frame.DataFrame = pd._testing.DataFrame = LuxDataFrame
pd.Series = pd.core.series.Series = pd.core.groupby.ops.Series = pd._testing.Series = LuxSeries
pd.core.groupby.generic.DataFrameGroupBy = LuxDataFrameGroupBy
pd.core.groupby.generic.SeriesGroupBy = LuxSeriesGroupBy
Expand Down
1 change: 1 addition & 0 deletions lux/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class LuxSeries(pd.Series):
"_pandas_only",
"pre_aggregated",
"_type_override",
"name",
]

_default_metadata = {
Expand Down
1 change: 1 addition & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,5 @@ def global_var():
"_pandas_only",
"pre_aggregated",
"_type_override",
"name",
]
11 changes: 11 additions & 0 deletions tests/test_pandas_coverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,17 @@ def test_deepcopy(global_var):
check_metadata_equal(df, saved_df)


def test_create_ldf_from_ldf(global_var):
import pandas._testing as tm

df = tm.makeDataFrame()
df._ipython_display_()
saved_df = lux.LuxDataFrame(df)
saved_df._ipython_display_()
assert len(df.columns) == len(saved_df.columns)
assert all([a == b for a, b in zip(df.columns, saved_df.columns)])


def test_rename_inplace(global_var):
df = pd.read_csv("lux/data/car.csv")
df["Year"] = pd.to_datetime(df["Year"], format="%Y")
Expand Down
1 change: 1 addition & 0 deletions tests/test_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def test_df_to_series():
"_pandas_only",
"pre_aggregated",
"_type_override",
"name",
], "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."
Expand Down

0 comments on commit 4d46ad9

Please sign in to comment.