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

Fix issue with read_json and add tests for different file types #156

Merged
merged 11 commits into from
Nov 26, 2020
4 changes: 3 additions & 1 deletion lux/core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@

def setOption(overridePandas=True):
if overridePandas:
pd.DataFrame = pd.io.parsers.DataFrame = pd.core.frame.DataFrame = LuxDataFrame
pd.DataFrame = (
pd.io.json._json.DataFrame
) = pd.io.parsers.DataFrame = pd.core.frame.DataFrame = LuxDataFrame
else:
pd.DataFrame = pd.io.parsers.DataFrame = pd.core.frame.DataFrame = originalDF

Expand Down
26 changes: 26 additions & 0 deletions tests/test_pandas_coverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -560,3 +560,29 @@ def test_str_replace(global_var):
], "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 == "Brand", "Pandas Series original `name` property not retained."


################
# Read Tests #
################


def test_read_json(global_var):
url = "https://raw.githubusercontent.com/lux-org/lux-datasets/master/data/car.json"
df = pd.read_json(url)
df._repr_html_()
assert list(df.recommendation.keys()) == [
"Correlation",
"Distribution",
"Occurrence",
"Temporal",
]
assert len(df.data_type_lookup) == 10


def test_read_sas(global_var):
url = "https://github.com/lux-org/lux-datasets/blob/master/data/airline.sas7bdat?raw=true"
df = pd.read_sas(url, format="sas7bdat")
df._repr_html_()
assert list(df.recommendation.keys()) == ["Correlation", "Distribution", "Temporal"]
assert len(df.data_type_lookup) == 6