-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
BUG: transpose inferring dtype for dt in object column #51565
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
Changes from 6 commits
9021944
0cf4e4c
3e8dc57
e5af65c
9926631
1522f8f
e2edec6
491200a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3555,7 +3555,11 @@ def transpose(self, *args, copy: bool = False) -> DataFrame: | |
new_vals = new_vals.copy() | ||
|
||
result = self._constructor( | ||
new_vals, index=self.columns, columns=self.index, copy=False | ||
new_vals, | ||
index=self.columns, | ||
columns=self.index, | ||
copy=False, | ||
dtype=new_vals.dtype, | ||
) | ||
if using_copy_on_write() and len(self) > 0: | ||
result._mgr.add_references(self._mgr) # type: ignore[arg-type] | ||
|
@@ -3577,7 +3581,9 @@ def transpose(self, *args, copy: bool = False) -> DataFrame: | |
new_arr = self.values.T | ||
if copy: | ||
new_arr = new_arr.copy() | ||
result = self._constructor(new_arr, index=self.columns, columns=self.index) | ||
result = self._constructor( | ||
new_arr, index=self.columns, columns=self.index, dtype=new_arr.dtype | ||
) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we need to pass copy=False here (possibly just to be future-safe)? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep, I’ll add it in the copy=True pr. actually, it probably makes sense to go through all usages of constructor and pass copy=False for arrays. Will take a look how many there are |
||
|
||
return result.__finalize__(self, method="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.
is this intentional?
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.
Nope thx, already removed. Snuck in