Skip to content

Commit eeb3d85

Browse files
committed
Added note to take method.
1 parent e0ff0d0 commit eeb3d85

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

pandas/core/arrays/_mixins.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,22 @@ def take(
174174
fill_value=fill_value,
175175
axis=axis,
176176
)
177+
# One of the base classes to this class: ExtensionArray, provides
178+
# the dtype property, but abstractly, so it leaves the implementation
179+
# of dtype storage up to its derived classes. Some of these derived
180+
# classes don't provide a setter method for their dtype property, so
181+
# I can't set the dtype here and expect it to work for all classes that
182+
# inherit this take method.
183+
184+
# How can I produce an extension array of the same type as self,
185+
# having a floating-point dtype if self has an integer dtype or otherwise
186+
# the same dtype as self?
187+
188+
# Constructing a new object of the same type as self doesn't always
189+
# work since the constructors of some derived classes of this class
190+
# don't accept a dtype parameter, which I need to pass to set the
191+
# result's dtype to a floating-point type.
192+
177193
if self.dtype in [
178194
NumpyEADtype(np.uint8),
179195
NumpyEADtype(np.uint16),

0 commit comments

Comments
 (0)