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

TST: add test for df construction from dict with tuples #29497

Merged

Conversation

ganevgv
Copy link
Contributor

@ganevgv ganevgv commented Nov 9, 2019

[([("a",), ("a",)], [1, 2]), ([("a",), ("b",)], [1, 2]), ([("a", "b")], [1])],
)
def test_constructor_from_dict_tuples(self, keys, values):
data_dict = {key: value for key, value in zip(keys, values)}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you just parametrize dictionaries directly instead of doing this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @WillAyd - incorporated the change.

@gfyoung gfyoung added the DataFrame DataFrame data structure label Nov 9, 2019
@gfyoung gfyoung added this to the 1.0 milestone Nov 9, 2019
df = DataFrame.from_dict(data_dict)

result = df.columns
all_columns = [key for sub_dict in data_dict for key in sub_dict.keys()]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can just parametrize the expected column values alongside the data instead of doing this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

got you - done

Copy link
Member

@WillAyd WillAyd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm @mroeschke care to take a look?

@mroeschke mroeschke merged commit 404e6ba into pandas-dev:master Nov 9, 2019
@mroeschke
Copy link
Member

Thanks @ganevgv!

keechongtan added a commit to keechongtan/pandas that referenced this pull request Nov 11, 2019
…ndexing-1row-df

* upstream/master: (109 commits)
  stronger typing in libreduction (pandas-dev#29502)
  API: rename labels to codes (pandas-dev#29509)
  CLN: remove unnecessary type checks (pandas-dev#29517)
  implement _BaseGrouper (pandas-dev#29520)
  CLN: F-string formatting in pandas/_libs/*.pyx (pandas-dev#29527)
  Fixed more SS03 errors (pandas-dev#29540)
  consolidate dim checks (pandas-dev#29536)
  REF: separate out _get_cython_func_and_vals (pandas-dev#29537)
  remove unnecessary exception (pandas-dev#29538)
  TST:Add test to check single category col returns series with single row slice (pandas-dev#29521)
  Make color validation more forgiving (pandas-dev#29122)
  DOC: update bottleneck repo and documentation urls (pandas-dev#29516)
  TST: add test for df construction from dict with tuples (pandas-dev#29497)
  add test for pd.melt dtypes preservation (pandas-dev#29510)
  updated DataFrame.equals docstring (pandas-dev#29496)
  Resolved merge conflicts (pandas-dev#29506)
  DOC: Improved pandas/compact/__init__.py (pandas-dev#29507)
  DOC: Update performance comparison section of io docs (pandas-dev#28890)
  TST: add test for df.where() with category dtype (pandas-dev#29454)
  DOC: Fix docs on merging categoricals. (pandas-dev#28185)
  ...
Reksbril pushed a commit to Reksbril/pandas that referenced this pull request Nov 18, 2019
…9497)

* add test for frame construction from dict with tuples

* parametrize full data_dict

* refactor parametrize
proost pushed a commit to proost/pandas that referenced this pull request Dec 19, 2019
…9497)

* add test for frame construction from dict with tuples

* parametrize full data_dict

* refactor parametrize
proost pushed a commit to proost/pandas that referenced this pull request Dec 19, 2019
…9497)

* add test for frame construction from dict with tuples

* parametrize full data_dict

* refactor parametrize
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DataFrame DataFrame data structure
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DataFrame.from_dict unexpectedly "flatten" tuples in the dictionary keys
4 participants