-
Notifications
You must be signed in to change notification settings - Fork 47
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
feat: Add transpose support for small homogeneously typed DataFrames. #621
Conversation
There was a problem hiding this 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`. |
There was a problem hiding this comment.
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.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added
@@ -2465,6 +2465,24 @@ def test_df_describe(scalars_dfs): | |||
).all() | |||
|
|||
|
|||
def test_df_transpose(): |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added
bigframes/core/blocks.py
Outdated
@@ -1570,6 +1575,52 @@ def melt( | |||
index_columns=[index_id], | |||
) | |||
|
|||
def transpose(self) -> Block: | |||
"""Transpose the block. Will fail if dtypes incompatible or too many rows""" |
There was a problem hiding this comment.
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."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
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:
Fixes #<issue_number_goes_here> 🦕