Skip to content

Commit

Permalink
update test_flatten [pd, list] with_nested_columns_with_nested_values…
Browse files Browse the repository at this point in the history
… making it pass
  • Loading branch information
FelipeSBarros committed May 17, 2024
1 parent 4270969 commit 22ef83d
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions tests/test_flatten.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from copy import deepcopy
from unittest.mock import Mock, patch

try:
Expand Down Expand Up @@ -250,9 +251,10 @@ def test_flatten_df_with_all_rows_missing_nested_values():


def test_flatten_list_dicts_with_nested_columns_with_nested_values():
data = [deepcopy(d) for d in DICT_DATA_WITH_NESTED_VALUES_IN_NESTED_COLUMNS]
assert (
flatten(
DICT_DATA_WITH_NESTED_VALUES_IN_NESTED_COLUMNS,
data,
nested_columns=["contextInfo"],
)
== EXPECTED_DICT_RETURN_WITH_NESTED_VALUES_IN_NESTED_COLUMNS
Expand All @@ -261,12 +263,12 @@ def test_flatten_list_dicts_with_nested_columns_with_nested_values():

@skip_if_pandas_not_installed
def test_flatten_pd_with_nested_columns_with_nested_values():
flattened_pd = flatten(
DataFrame(DICT_DATA_WITH_NESTED_VALUES_IN_NESTED_COLUMNS),
nested_columns=["contextInfo"],
)
flattened_pd.columns
data = [deepcopy(d) for d in DICT_DATA_WITH_NESTED_VALUES_IN_NESTED_COLUMNS]

assert_frame_equal(
flattened_pd,
flatten(
DataFrame(data),
nested_columns=["contextInfo"],
),
DataFrame(EXPECTED_DICT_RETURN_WITH_NESTED_VALUES_IN_NESTED_COLUMNS),
)

0 comments on commit 22ef83d

Please # to comment.