Skip to content
This repository was archived by the owner on Apr 1, 2026. It is now read-only.

feat: Add transpose support for small homogeneously typed DataFrames.#621

Merged
TrevorBergeron merged 4 commits intomainfrom
transpose3
Apr 23, 2024
Merged

feat: Add transpose support for small homogeneously typed DataFrames.#621
TrevorBergeron merged 4 commits intomainfrom
transpose3

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 chelsea-lin April 18, 2024 00:54
@product-auto-label product-auto-label bot added the size: m Pull request size is medium. label Apr 18, 2024
@product-auto-label product-auto-label bot added the api: bigquery Issues related to the googleapis/python-bigquery-dataframes API. label Apr 18, 2024
@TrevorBergeron TrevorBergeron requested review from milkshakeiii and removed request for chelsea-lin April 18, 2024 19:29
Copy link
Copy Markdown
Contributor

@milkshakeiii milkshakeiii left a comment

Choose a reason for hiding this comment

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

LGTM, just suggested we make it more clear in the docstrings exactly what the dtype restriction is.


Reflect the DataFrame over its main diagonal by writing rows as columns
and vice-versa. The property :attr:`.T` is an accessor to the method
:meth:`transpose`.
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.

Can we add something here about the dtypes requirements? (Columns must be coerceable to a common type) (I know it's below but seems important enough to be up top.)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

added

).all()


def test_df_transpose():
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.

If it's a cheap test, we could add a check that we raise TypeError for mixing strs and floats.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

added

)

def transpose(self) -> Block:
"""Transpose the block. Will fail if dtypes incompatible or too many rows"""
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.

Suggest we change "dtypes incompatible" to "dtypes cannot be coerced all to a common type."

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

@TrevorBergeron TrevorBergeron enabled auto-merge (squash) April 23, 2024 00:07
@TrevorBergeron TrevorBergeron merged commit 054075d into main Apr 23, 2024
@TrevorBergeron TrevorBergeron deleted the transpose3 branch April 23, 2024 01:20
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

api: bigquery Issues related to the googleapis/python-bigquery-dataframes API. size: m Pull request size is medium.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants