8000 BUG: preserve EA dtype in transpose by TomAugspurger · Pull Request #30091 · pandas-dev/pandas · GitHub
[go: up one dir, main page]

Skip to content

BUG: preserve EA dtype in transpose #30091

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

Merged
merged 20 commits into from
Dec 27, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
steal tests
  • Loading branch information
TomAugspurger committed Dec 6, 2019
commit 10d81bd018d2008b5bdf774b89696b09a01cec71
16 changes: 16 additions & 0 deletions pandas/tests/frame/test_operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -891,6 +891,22 @@ def test_no_warning(self, all_arithmetic_operators):


class TestTranspose:
@pytest.mark.parametrize(
"ser",
[
pd.date_range("2016-04-05 04:30", periods=3, tz="UTC"),
pd.period_range("1994", freq="A", periods=3),
pd.period_range("1969", freq="9s", periods=1),
pd.date_range("2016-04-05 04:30", periods=3).astype("category"),
pd.date_range("2016-04-05 04:30", periods=3, tz="UTC").astype("category"),
],
)
def test_transpose_retains_extension_dtype(self, ser):
# case with more than 1 column, must have same dtype
df = pd.DataFrame({"a": ser, "b": ser})
result = df.T
assert (result.dtypes == ser.dtype).all()

Copy link
Member

Choose a reason for hiding this comment

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

round_trip = df.T.T
tm.assert_frame_equal(df, round_trip)

?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Interestingly, the pd.date_range("2016-04-05 04:30", periods=3).astype("category") case fails that test. All the values are NaT.

I've xfalied it for now, and likely won't have time to look into it.

Copy link
Member

Choose a reason for hiding this comment

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

sounds good, thanks

def test_transpose_tzaware_1col_single_tz(self):
# GH#26825
dti = pd.date_range("2016-04-05 04:30", periods=3, tz="UTC")
Expand Down
0