Skip to content

feat: add df.unstack - #63

Merged
TrevorBergeron merged 4 commits into
mainfrom
neopivot
Sep 29, 2023
Merged

feat: add df.unstack#63
TrevorBergeron merged 4 commits into
mainfrom
neopivot

Conversation

@TrevorBergeron

Copy link
Copy Markdown
Contributor

Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:

  • Make sure to open an issue as a bug/issue before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea
  • Ensure the tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)

Fixes #<issue_number_goes_here> 🦕

@TrevorBergeron
TrevorBergeron requested review from a team and ashleyxuuSeptember 26, 2023 19:02
@product-auto-labelproduct-auto-labelBot added size: l Pull request size is large. api: bigquery Issues related to the googleapis/python-bigquery-dataframes API. labels Sep 26, 2023
Comment threadtests/system/small/test_dataframe.py
)


def test_column_multi_index_unstack(scalars_df_index, scalars_pandas_df_index):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[nit] would test_multi_column_unstack better represent this test?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

My naming convention is based on the initial dataframe object, column_multi_index indicating that the initial column axis is a multi-index. Open to changing this convention, but it is inline with how I've named the tests so far.

)
pd_result = hockey_pandas_df.set_index(
["team_name", "season", "position"]
).unstack()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think it would be worth testing for all levels: {-3, -2, -1, 0, 1, 2}

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

I don't support levels param yet. Will add levels support to stack() and unstack() in a later pr.

Comment threadtests/system/small/test_dataframe.py
@TrevorBergeron
TrevorBergeron merged commit 4a84714 into mainSep 29, 2023
@TrevorBergeron
TrevorBergeron deleted the neopivot branch September 29, 2023 21:16
@release-pleaserelease-pleaseBot mentioned this pull request Sep 29, 2023
ashleyxuu pushed a commit that referenced this pull request Oct 3, 2023
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: bigqueryIssues related to the googleapis/python-bigquery-dataframes API.size: lPull request size is large.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@TrevorBergeron@shobsi