<p dir="auto">Hi,</p>
<p dir="auto">I have recently come across an unexpexted behaviour of the dataframe "shift" function.<br>
When column titles are duplicated (or present more often), a column-specific shift using index-based positioning (by "iloc") does not only shift the specified columns, but all columns sharing the same name. From the behaviour I guess that internally, the column names and not the indices are used, causing all identically named columns to shift.<br>
This behaviour did not occur (at least to my knowledge ) with v. 0.13, but is present in both 0.15.1 and 0.15.2.<br>
Please find attached a small code snippet which demonstrates the behaviour, and the system information.</p>
<p dir="auto">Thanks a lot for any help</p>
<p dir="auto">Kay</p>
<h4 dir="auto">Begin example code</h4>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="from pandas import *
import pandas as pd


data = DataFrame(np.random.randn(20, 5)) # Generating a random data frame
data2 = data.copy()
data3 = data.copy()
shifting_matrix = [1,2,3,4,5] # shifting matrix - we want to shift the columns by these values


#Shifting the columns:  Expected behaviour. Column 1 is shifter by 1, Column 2 by 2 and so on

for position, movement in enumerate(shifting_matrix):
    print position 
    print movement
    data.iloc[:, position] = data.iloc[:,position].shift(movement)



## Changing the titles of the dataframe
titles = [1,1,1,1,1]
data2.columns = titles

# Shifting the columns again. Since we are using index based positions, the shifting behaviour should be the same as above
for position, movement in enumerate(shifting_matrix):
    print position 
    print movement
    data2.iloc[:, position] = data2.iloc[:,position].shift(movement)



titles2 = [1,1,2,2,1] # Making mixed column titles, duplicating
data3.columns = titles2
# Shifting the columns again. Since we are using index based positions, the shifting behaviour should be the same as above
for position, movement in enumerate(shifting_matrix):
    print position 
    print movement
    data3.iloc[:, position] = data3.iloc[:,position].shift(movement)

print data
print data2
print data3
"><pre class="notranslate"><span class="pl-k">from</span> <span class="pl-s1">pandas</span> <span class="pl-k">import</span> <span class="pl-c1">*</span>
<span class="pl-k">import</span> <span class="pl-s1">pandas</span> <span class="pl-k">as</span> <span class="pl-s1">pd</span>


<span class="pl-s1">data</span> <span class="pl-c1">=</span> <span class="pl-v">DataFrame</span>(<span class="pl-s1">np</span>.<span class="pl-s1">random</span>.<span class="pl-en">randn</span>(<span class="pl-c1">20</span>, <span class="pl-c1">5</span>)) <span class="pl-c"># Generating a random data frame</span>
<span class="pl-s1">data2</span> <span class="pl-c1">=</span> <span class="pl-s1">data</span>.<span class="pl-en">copy</span>()
<span class="pl-s1">data3</span> <span class="pl-c1">=</span> <span class="pl-s1">data</span>.<span class="pl-en">copy</span>()
<span class="pl-s1">shifting_matrix</span> <span class="pl-c1">=</span> [<span class="pl-c1">1</span>,<span class="pl-c1">2</span>,<span class="pl-c1">3</span>,<span class="pl-c1">4</span>,<span class="pl-c1">5</span>] <span class="pl-c"># shifting matrix - we want to shift the columns by these values</span>


<span class="pl-c">#Shifting the columns:  Expected behaviour. Column 1 is shifter by 1, Column 2 by 2 and so on</span>

<span class="pl-k">for</span> <span class="pl-s1">position</span>, <span class="pl-s1">movement</span> <span class="pl-c1">in</span> <span class="pl-en">enumerate</span>(<span class="pl-s1">shifting_matrix</span>):
    <span class="pl-k">print</span> <span class="pl-s1">position</span> 
    <span class="pl-k">print</span> <span class="pl-s1">movement</span>
    <span class="pl-s1">data</span>.<span class="pl-s1">iloc</span>[:, <span class="pl-s1">position</span>] <span class="pl-c1">=</span> <span class="pl-s1">data</span>.<span class="pl-s1">iloc</span>[:,<span class="pl-s1">position</span>].<span class="pl-en">shift</span>(<span class="pl-s1">movement</span>)



<span class="pl-c">## Changing the titles of the dataframe</span>
<span class="pl-s1">titles</span> <span class="pl-c1">=</span> [<span class="pl-c1">1</span>,<span class="pl-c1">1</span>,<span class="pl-c1">1</span>,<span class="pl-c1">1</span>,<span class="pl-c1">1</span>]
<span class="pl-s1">data2</span>.<span class="pl-s1">columns</span> <span class="pl-c1">=</span> <span class="pl-s1">titles</span>

<span class="pl-c"># Shifting the columns again. Since we are using index based positions, the shifting behaviour should be the same as above</span>
<span class="pl-k">for</span> <span class="pl-s1">position</span>, <span class="pl-s1">movement</span> <span class="pl-c1">in</span> <span class="pl-en">enumerate</span>(<span class="pl-s1">shifting_matrix</span>):
    <span class="pl-k">print</span> <span class="pl-s1">position</span> 
    <span class="pl-k">print</span> <span class="pl-s1">movement</span>
    <span class="pl-s1">data2</span>.<span class="pl-s1">iloc</span>[:, <span class="pl-s1">position</span>] <span class="pl-c1">=</span> <span class="pl-s1">data2</span>.<span class="pl-s1">iloc</span>[:,<span class="pl-s1">position</span>].<span class="pl-en">shift</span>(<span class="pl-s1">movement</span>)



<span class="pl-s1">titles2</span> <span class="pl-c1">=</span> [<span class="pl-c1">1</span>,<span class="pl-c1">1</span>,<span class="pl-c1">2</span>,<span class="pl-c1">2</span>,<span class="pl-c1">1</span>] <span class="pl-c"># Making mixed column titles, duplicating</span>
<span class="pl-s1">data3</span>.<span class="pl-s1">columns</span> <span class="pl-c1">=</span> <span class="pl-s1">titles2</span>
<span class="pl-c"># Shifting the columns again. Since we are using index based positions, the shifting behaviour should be the same as above</span>
<span class="pl-k">for</span> <span class="pl-s1">position</span>, <span class="pl-s1">movement</span> <span class="pl-c1">in</span> <span class="pl-en">enumerate</span>(<span class="pl-s1">shifting_matrix</span>):
    <span class="pl-k">print</span> <span class="pl-s1">position</span> 
    <span class="pl-k">print</span> <span class="pl-s1">movement</span>
    <span class="pl-s1">data3</span>.<span class="pl-s1">iloc</span>[:, <span class="pl-s1">position</span>] <span class="pl-c1">=</span> <span class="pl-s1">data3</span>.<span class="pl-s1">iloc</span>[:,<span class="pl-s1">position</span>].<span class="pl-en">shift</span>(<span class="pl-s1">movement</span>)

<span class="pl-k">print</span> <span class="pl-s1">data</span>
<span class="pl-k">print</span> <span class="pl-s1">data2</span>
<span class="pl-k">print</span> <span class="pl-s1">data3</span></pre></div>
<h4 dir="auto">End example code</h4>
<h2 dir="auto">INSTALLED VERSIONS</h2>
<p dir="auto">commit: None<br>
python: 2.7.6.final.0<br>
python-bits: 32<br>
OS: Windows<br>
OS-release: 7<br>
machine: AMD64<br>
processor: Intel64 Family 6 Model 58 Stepping 9, GenuineIntel<br>
byteorder: little<br>
LC_ALL: None<br>
LANG: nb_NO</p>
<p dir="auto">pandas: 0.15.2<br>
nose: 1.3.3<br>
Cython: 0.20.1<br>
numpy: 1.8.1<br>
scipy: 0.14.0<br>
statsmodels: 0.5.0<br>
IPython: 2.1.0<br>
sphinx: 1.2.2<br>
patsy: 0.2.1<br>
dateutil: 2.2<br>
pytz: 2014.3<br>
bottleneck: 0.8.0<br>
tables: None<br>
numexpr: 2.4<br>
matplotlib: 1.3.1<br>
openpyxl: 2.1.0<br>
xlrd: None<br>
xlwt: 0.7.5<br>
xlsxwriter: 0.5.8<br>
lxml: 3.3.5<br>
bs4: 4.3.2<br>
html5lib: 0.999<br>
httplib2: None<br>
apiclient: None<br>
rpy2: None<br>
sqlalchemy: 0.9.4<br>
pymysql: None<br>
psycopg2: None</p>
<h4 dir="auto">Code Sample, a copy-pastable example if possible</h4>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="class NumPyBackedExtensionArrayMixin(ExtensionArray):
    &quot;&quot;&quot;
    Geo-Specific Extension Array Mixin
    &quot;&quot;&quot;
    @property
    def dtype(self):
        &quot;&quot;&quot;The dtype for this extension array, GeoType&quot;&quot;&quot;
        return self._dtype

    @classmethod
    def _constructor_from_sequence(cls, scalars):
        return cls(scalars)

    @classmethod
    def _from_factorized(cls, values, original):
        return cls(values)

    @property
    def shape(self):
        return (len(self.data),)

    def __len__(self):
        return len(self.data)

    def __getitem__(self, *args):
        result = operator.getitem(self.data, *args)
        return result
        #if isinstance(result, tuple):
            #return self._box_scalar(result)
        #elif result.ndim == 0:
            #return self._box_scalar(result.item())
        #else:
            #return type(self)(result)

    def setitem(self, indexer, value):
        &quot;&quot;&quot;Set the 'value' inplace.
        &quot;&quot;&quot;

        self[indexer] = value
        return self

    @property
    def nbytes(self):
        return self._itemsize * len(self)

    def _formatting_values(self):
        return np.array(self._format_values(), dtype='object')

    def copy(self, deep=False):
        return type(self)(self.data.copy())

    @classmethod
    def _concat_same_type(cls, to_concat):
        return cls(np.concatenate([array.data for array in to_concat]))

    def tolist(self):
        return self.data.tolist()

    def argsort(self, axis=-1, kind='quicksort', order=None):
        return self.data.argsort()

    def unique(self):
        _, indices = np.unique(self.data, return_index=True)
        data = self.data.take(np.sort(indices))
        return self._from_ndarray(data)


class GeoType(ExtensionDtype):
    name = 'geometry'
    type = Geometry
    kind = 'O'
    _record_type = np.dtype('O')
    na_value = None

    @classmethod
    def construct_from_string(cls, string):
        if string == cls.name:
            return cls()
        else:
            raise TypeError(&quot;Cannot construct a '{}' from &quot;
                            &quot;'{}'&quot;.format(cls, string))

class GeoArray(NumPyBackedExtensionArrayMixin):
    &quot;&quot;&quot;Array for Geometry data.
    &quot;&quot;&quot;
    # What type(s) do we support?
    # MAC-48 or EUI-64?
    _dtype = GeoType()
    _itemsize = 8
    ndim = 1
    can_hold_na = True

    def __init__(self, values, copy=True):
        # TODO: parse hex / strings
        self.data = np.array(values, dtype='O', copy=copy)

    @classmethod
    def _from_ndarray(cls, data, copy=False):
        return cls(data, copy=copy)

    @property
    def na_value(self):
        return self.dtype.na_value

    def __repr__(self):
        formatted = self._format_values()
        return &quot;GeoArray({!r})&quot;.format(formatted)
    
    def _format_values(self):
        return [_format(x) for x in self.data]

    @classmethod
    def from_geometry(cls, data, copy=False):
        &quot;&quot;&quot;&quot;&quot;&quot;
        if copy:
            data = data.copy()
        new = GeoArray([])
        new.data = np.array(data)
        return new

    def __setitem__(self, key, value):
        value = Geometry(value)
        self.data[key] = value

    def __iter__(self):
        return iter(self.data.tolist())

    def __eq__(self, other):
        return self.data == other

    def equals(self, other):
        if not isinstance(other, type(self)):
            raise TypeError
        return (self.data == other.data).all()

    def _values_for_factorize(self):
        # Should hit pandas' UInt64Hashtable
        return self, 0

    def isna(self):
        return (self.data == self._dtype.na_value)

    @property
    def _parser(self):
        return lambda x: x

    def take(self, indexer, allow_fill=True, fill_value=None):
        mask = indexer == -1
        result = self.data.take(indexer)
        result[mask] = self.dtype.na_value
        return type(self)(result, copy=False)

    def _formatting_values(self):
        return np.array(self._format_values(), dtype='object')

    @classmethod
    def _concat_same_type(cls, to_concat):
        return cls(np.concatenate([array.data for array in to_concat]))

    def take_nd(self, indexer, allow_fill=True, fill_value=None):
        return self.take(indexer, allow_fill=allow_fill, fill_value=fill_value)

    def copy(self, deep=False):
        return type(self)(self.data.copy())

    from arcgis.geometry import BaseGeometry
    @property
    def is_valid(self):
        &quot;&quot;&quot;Checks if the Geometry is Valid&quot;&quot;&quot;
        return pd.Series([g.is_valid for g in self])

#### TO GET THE ERROR
&gt;&gt;&gt; geoms = [{
  &quot;rings&quot; : [[[-97.06138,32.837],[-97.06133,32.836],[-97.06124,32.834],[-97.06127,32.832],
              [-97.06138,32.837]],[[-97.06326,32.759],[-97.06298,32.755],[-97.06153,32.749],
              [-97.06326,32.759]]],
  &quot;spatialReference&quot; : {&quot;wkid&quot; : 4326}
}
]
&gt;&gt;&gt; v = GeoArray(geoms)
&gt;&gt;&gt; df = pd.DataFrame({&quot;SHAPE&quot;: v})
&gt;&gt;&gt; small = df.head(1)
&gt;&gt;&gt; print(small)

"><pre class="notranslate"><span class="pl-k">class</span> <span class="pl-v">NumPyBackedExtensionArrayMixin</span>(<span class="pl-v">ExtensionArray</span>):
    <span class="pl-s">"""</span>
<span class="pl-s">    Geo-Specific Extension Array Mixin</span>
<span class="pl-s">    """</span>
    <span class="pl-en">@<span class="pl-s1">property</span></span>
    <span class="pl-k">def</span> <span class="pl-en">dtype</span>(<span class="pl-s1">self</span>):
        <span class="pl-s">"""The dtype for this extension array, GeoType"""</span>
        <span class="pl-k">return</span> <span class="pl-s1">self</span>.<span class="pl-s1">_dtype</span>

    <span class="pl-en">@<span class="pl-s1">classmethod</span></span>
    <span class="pl-k">def</span> <span class="pl-en">_constructor_from_sequence</span>(<span class="pl-s1">cls</span>, <span class="pl-s1">scalars</span>):
        <span class="pl-k">return</span> <span class="pl-en">cls</span>(<span class="pl-s1">scalars</span>)

    <span class="pl-en">@<span class="pl-s1">classmethod</span></span>
    <span class="pl-k">def</span> <span class="pl-en">_from_factorized</span>(<span class="pl-s1">cls</span>, <span class="pl-s1">values</span>, <span class="pl-s1">original</span>):
        <span class="pl-k">return</span> <span class="pl-en">cls</span>(<span class="pl-s1">values</span>)

    <span class="pl-en">@<span class="pl-s1">property</span></span>
    <span class="pl-k">def</span> <span class="pl-en">shape</span>(<span class="pl-s1">self</span>):
        <span class="pl-k">return</span> (<span class="pl-en">len</span>(<span class="pl-s1">self</span>.<span class="pl-s1">data</span>),)

    <span class="pl-k">def</span> <span class="pl-en">__len__</span>(<span class="pl-s1">self</span>):
        <span class="pl-k">return</span> <span class="pl-en">len</span>(<span class="pl-s1">self</span>.<span class="pl-s1">data</span>)

    <span class="pl-k">def</span> <span class="pl-en">__getitem__</span>(<span class="pl-s1">self</span>, <span class="pl-c1">*</span><span class="pl-s1">args</span>):
        <span class="pl-s1">result</span> <span class="pl-c1">=</span> <span class="pl-s1">operator</span>.<span class="pl-en">getitem</span>(<span class="pl-s1">self</span>.<span class="pl-s1">data</span>, <span class="pl-c1">*</span><span class="pl-s1">args</span>)
        <span class="pl-k">return</span> <span class="pl-s1">result</span>
        <span class="pl-c">#if isinstance(result, tuple):</span>
            <span class="pl-c">#return self._box_scalar(result)</span>
        <span class="pl-c">#elif result.ndim == 0:</span>
            <span class="pl-c">#return self._box_scalar(result.item())</span>
        <span class="pl-c">#else:</span>
            <span class="pl-c">#return type(self)(result)</span>

    <span class="pl-k">def</span> <span class="pl-en">setitem</span>(<span class="pl-s1">self</span>, <span class="pl-s1">indexer</span>, <span class="pl-s1">value</span>):
        <span class="pl-s">"""Set the 'value' inplace.</span>
<span class="pl-s">        """</span>

        <span class="pl-s1">self</span>[<span class="pl-s1">indexer</span>] <span class="pl-c1">=</span> <span class="pl-s1">value</span>
        <span class="pl-k">return</span> <span class="pl-s1">self</span>

    <span class="pl-en">@<span class="pl-s1">property</span></span>
    <span class="pl-k">def</span> <span class="pl-en">nbytes</span>(<span class="pl-s1">self</span>):
        <span class="pl-k">return</span> <span class="pl-s1">self</span>.<span class="pl-s1">_itemsize</span> <span class="pl-c1">*</span> <span class="pl-en">len</span>(<span class="pl-s1">self</span>)

    <span class="pl-k">def</span> <span class="pl-en">_formatting_values</span>(<span class="pl-s1">self</span>):
        <span class="pl-k">return</span> <span class="pl-s1">np</span>.<span class="pl-en">array</span>(<span class="pl-s1">self</span>.<span class="pl-en">_format_values</span>(), <span class="pl-s1">dtype</span><span class="pl-c1">=</span><span class="pl-s">'object'</span>)

    <span class="pl-k">def</span> <span class="pl-en">copy</span>(<span class="pl-s1">self</span>, <span class="pl-s1">deep</span><span class="pl-c1">=</span><span class="pl-c1">False</span>):
        <span class="pl-k">return</span> <span class="pl-en">type</span>(<span class="pl-s1">self</span>)(<span class="pl-s1">self</span>.<span class="pl-s1">data</span>.<span class="pl-en">copy</span>())

    <span class="pl-en">@<span class="pl-s1">classmethod</span></span>
    <span class="pl-k">def</span> <span class="pl-en">_concat_same_type</span>(<span class="pl-s1">cls</span>, <span class="pl-s1">to_concat</span>):
        <span class="pl-k">return</span> <span class="pl-en">cls</span>(<span class="pl-s1">np</span>.<span class="pl-en">concatenate</span>([<span class="pl-s1">array</span>.<span class="pl-s1">data</span> <span class="pl-k">for</span> <span class="pl-s1">array</span> <span class="pl-c1">in</span> <span class="pl-s1">to_concat</span>]))

    <span class="pl-k">def</span> <span class="pl-en">tolist</span>(<span class="pl-s1">self</span>):
        <span class="pl-k">return</span> <span class="pl-s1">self</span>.<span class="pl-s1">data</span>.<span class="pl-en">tolist</span>()

    <span class="pl-k">def</span> <span class="pl-en">argsort</span>(<span class="pl-s1">self</span>, <span class="pl-s1">axis</span><span class="pl-c1">=</span><span class="pl-c1">-</span><span class="pl-c1">1</span>, <span class="pl-s1">kind</span><span class="pl-c1">=</span><span class="pl-s">'quicksort'</span>, <span class="pl-s1">order</span><span class="pl-c1">=</span><span class="pl-c1">None</span>):
        <span class="pl-k">return</span> <span class="pl-s1">self</span>.<span class="pl-s1">data</span>.<span class="pl-en">argsort</span>()

    <span class="pl-k">def</span> <span class="pl-en">unique</span>(<span class="pl-s1">self</span>):
        <span class="pl-s1">_</span>, <span class="pl-s1">indices</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">unique</span>(<span class="pl-s1">self</span>.<span class="pl-s1">data</span>, <span class="pl-s1">return_index</span><span class="pl-c1">=</span><span class="pl-c1">True</span>)
        <span class="pl-s1">data</span> <span class="pl-c1">=</span> <span class="pl-s1">self</span>.<span class="pl-s1">data</span>.<span class="pl-en">take</span>(<span class="pl-s1">np</span>.<span class="pl-en">sort</span>(<span class="pl-s1">indices</span>))
        <span class="pl-k">return</span> <span class="pl-s1">self</span>.<span class="pl-en">_from_ndarray</span>(<span class="pl-s1">data</span>)


<span class="pl-k">class</span> <span class="pl-v">GeoType</span>(<span class="pl-v">ExtensionDtype</span>):
    <span class="pl-s1">name</span> <span class="pl-c1">=</span> <span class="pl-s">'geometry'</span>
    <span class="pl-s1">type</span> <span class="pl-c1">=</span> <span class="pl-v">Geometry</span>
    <span class="pl-s1">kind</span> <span class="pl-c1">=</span> <span class="pl-s">'O'</span>
    <span class="pl-s1">_record_type</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">dtype</span>(<span class="pl-s">'O'</span>)
    <span class="pl-s1">na_value</span> <span class="pl-c1">=</span> <span class="pl-c1">None</span>

    <span class="pl-en">@<span class="pl-s1">classmethod</span></span>
    <span class="pl-k">def</span> <span class="pl-en">construct_from_string</span>(<span class="pl-s1">cls</span>, <span class="pl-s1">string</span>):
        <span class="pl-k">if</span> <span class="pl-s1">string</span> <span class="pl-c1">==</span> <span class="pl-s1">cls</span>.<span class="pl-s1">name</span>:
            <span class="pl-k">return</span> <span class="pl-en">cls</span>()
        <span class="pl-k">else</span>:
            <span class="pl-k">raise</span> <span class="pl-v">TypeError</span>(<span class="pl-s">"Cannot construct a '{}' from "</span>
                            <span class="pl-s">"'{}'"</span>.<span class="pl-en">format</span>(<span class="pl-s1">cls</span>, <span class="pl-s1">string</span>))

<span class="pl-k">class</span> <span class="pl-v">GeoArray</span>(<span class="pl-v">NumPyBackedExtensionArrayMixin</span>):
    <span class="pl-s">"""Array for Geometry data.</span>
<span class="pl-s">    """</span>
    <span class="pl-c"># What type(s) do we support?</span>
    <span class="pl-c"># MAC-48 or EUI-64?</span>
    <span class="pl-s1">_dtype</span> <span class="pl-c1">=</span> <span class="pl-v">GeoType</span>()
    <span class="pl-s1">_itemsize</span> <span class="pl-c1">=</span> <span class="pl-c1">8</span>
    <span class="pl-s1">ndim</span> <span class="pl-c1">=</span> <span class="pl-c1">1</span>
    <span class="pl-s1">can_hold_na</span> <span class="pl-c1">=</span> <span class="pl-c1">True</span>

    <span class="pl-k">def</span> <span class="pl-en">__init__</span>(<span class="pl-s1">self</span>, <span class="pl-s1">values</span>, <span class="pl-s1">copy</span><span class="pl-c1">=</span><span class="pl-c1">True</span>):
        <span class="pl-c"># TODO: parse hex / strings</span>
        <span class="pl-s1">self</span>.<span class="pl-s1">data</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">array</span>(<span class="pl-s1">values</span>, <span class="pl-s1">dtype</span><span class="pl-c1">=</span><span class="pl-s">'O'</span>, <span class="pl-s1">copy</span><span class="pl-c1">=</span><span class="pl-s1">copy</span>)

    <span class="pl-en">@<span class="pl-s1">classmethod</span></span>
    <span class="pl-k">def</span> <span class="pl-en">_from_ndarray</span>(<span class="pl-s1">cls</span>, <span class="pl-s1">data</span>, <span class="pl-s1">copy</span><span class="pl-c1">=</span><span class="pl-c1">False</span>):
        <span class="pl-k">return</span> <span class="pl-en">cls</span>(<span class="pl-s1">data</span>, <span class="pl-s1">copy</span><span class="pl-c1">=</span><span class="pl-s1">copy</span>)

    <span class="pl-en">@<span class="pl-s1">property</span></span>
    <span class="pl-k">def</span> <span class="pl-en">na_value</span>(<span class="pl-s1">self</span>):
        <span class="pl-k">return</span> <span class="pl-s1">self</span>.<span class="pl-s1">dtype</span>.<span class="pl-s1">na_value</span>

    <span class="pl-k">def</span> <span class="pl-en">__repr__</span>(<span class="pl-s1">self</span>):
        <span class="pl-s1">formatted</span> <span class="pl-c1">=</span> <span class="pl-s1">self</span>.<span class="pl-en">_format_values</span>()
        <span class="pl-k">return</span> <span class="pl-s">"GeoArray({!r})"</span>.<span class="pl-en">format</span>(<span class="pl-s1">formatted</span>)
    
    <span class="pl-k">def</span> <span class="pl-en">_format_values</span>(<span class="pl-s1">self</span>):
        <span class="pl-k">return</span> [<span class="pl-en">_format</span>(<span class="pl-s1">x</span>) <span class="pl-k">for</span> <span class="pl-s1">x</span> <span class="pl-c1">in</span> <span class="pl-s1">self</span>.<span class="pl-s1">data</span>]

    <span class="pl-en">@<span class="pl-s1">classmethod</span></span>
    <span class="pl-k">def</span> <span class="pl-en">from_geometry</span>(<span class="pl-s1">cls</span>, <span class="pl-s1">data</span>, <span class="pl-s1">copy</span><span class="pl-c1">=</span><span class="pl-c1">False</span>):
        <span class="pl-s">""""""</span>
        <span class="pl-k">if</span> <span class="pl-s1">copy</span>:
            <span class="pl-s1">data</span> <span class="pl-c1">=</span> <span class="pl-s1">data</span>.<span class="pl-en">copy</span>()
        <span class="pl-s1">new</span> <span class="pl-c1">=</span> <span class="pl-v">GeoArray</span>([])
        <span class="pl-s1">new</span>.<span class="pl-s1">data</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">array</span>(<span class="pl-s1">data</span>)
        <span class="pl-k">return</span> <span class="pl-s1">new</span>

    <span class="pl-k">def</span> <span class="pl-en">__setitem__</span>(<span class="pl-s1">self</span>, <span class="pl-s1">key</span>, <span class="pl-s1">value</span>):
        <span class="pl-s1">value</span> <span class="pl-c1">=</span> <span class="pl-v">Geometry</span>(<span class="pl-s1">value</span>)
        <span class="pl-s1">self</span>.<span class="pl-s1">data</span>[<span class="pl-s1">key</span>] <span class="pl-c1">=</span> <span class="pl-s1">value</span>

    <span class="pl-k">def</span> <span class="pl-en">__iter__</span>(<span class="pl-s1">self</span>):
        <span class="pl-k">return</span> <span class="pl-en">iter</span>(<span class="pl-s1">self</span>.<span class="pl-s1">data</span>.<span class="pl-en">tolist</span>())

    <span class="pl-k">def</span> <span class="pl-en">__eq__</span>(<span class="pl-s1">self</span>, <span class="pl-s1">other</span>):
        <span class="pl-k">return</span> <span class="pl-s1">self</span>.<span class="pl-s1">data</span> <span class="pl-c1">==</span> <span class="pl-s1">other</span>

    <span class="pl-k">def</span> <span class="pl-en">equals</span>(<span class="pl-s1">self</span>, <span class="pl-s1">other</span>):
        <span class="pl-k">if</span> <span class="pl-c1">not</span> <span class="pl-en">isinstance</span>(<span class="pl-s1">other</span>, <span class="pl-en">type</span>(<span class="pl-s1">self</span>)):
            <span class="pl-k">raise</span> <span class="pl-v">TypeError</span>
        <span class="pl-k">return</span> (<span class="pl-s1">self</span>.<span class="pl-s1">data</span> <span class="pl-c1">==</span> <span class="pl-s1">other</span>.<span class="pl-s1">data</span>).<span class="pl-en">all</span>()

    <span class="pl-k">def</span> <span class="pl-en">_values_for_factorize</span>(<span class="pl-s1">self</span>):
        <span class="pl-c"># Should hit pandas' UInt64Hashtable</span>
        <span class="pl-k">return</span> <span class="pl-s1">self</span>, <span class="pl-c1">0</span>

    <span class="pl-k">def</span> <span class="pl-en">isna</span>(<span class="pl-s1">self</span>):
        <span class="pl-k">return</span> (<span class="pl-s1">self</span>.<span class="pl-s1">data</span> <span class="pl-c1">==</span> <span class="pl-s1">self</span>.<span class="pl-s1">_dtype</span>.<span class="pl-s1">na_value</span>)

    <span class="pl-en">@<span class="pl-s1">property</span></span>
    <span class="pl-k">def</span> <span class="pl-en">_parser</span>(<span class="pl-s1">self</span>):
        <span class="pl-k">return</span> <span class="pl-k">lambda</span> <span class="pl-s1">x</span>: <span class="pl-s1">x</span>

    <span class="pl-k">def</span> <span class="pl-en">take</span>(<span class="pl-s1">self</span>, <span class="pl-s1">indexer</span>, <span class="pl-s1">allow_fill</span><span class="pl-c1">=</span><span class="pl-c1">True</span>, <span class="pl-s1">fill_value</span><span class="pl-c1">=</span><span class="pl-c1">None</span>):
        <span class="pl-s1">mask</span> <span class="pl-c1">=</span> <span class="pl-s1">indexer</span> <span class="pl-c1">==</span> <span class="pl-c1">-</span><span class="pl-c1">1</span>
        <span class="pl-s1">result</span> <span class="pl-c1">=</span> <span class="pl-s1">self</span>.<span class="pl-s1">data</span>.<span class="pl-en">take</span>(<span class="pl-s1">indexer</span>)
        <span class="pl-s1">result</span>[<span class="pl-s1">mask</span>] <span class="pl-c1">=</span> <span class="pl-s1">self</span>.<span class="pl-s1">dtype</span>.<span class="pl-s1">na_value</span>
        <span class="pl-k">return</span> <span class="pl-en">type</span>(<span class="pl-s1">self</span>)(<span class="pl-s1">result</span>, <span class="pl-s1">copy</span><span class="pl-c1">=</span><span class="pl-c1">False</span>)

    <span class="pl-k">def</span> <span class="pl-en">_formatting_values</span>(<span class="pl-s1">self</span>):
        <span class="pl-k">return</span> <span class="pl-s1">np</span>.<span class="pl-en">array</span>(<span class="pl-s1">self</span>.<span class="pl-en">_format_values</span>(), <span class="pl-s1">dtype</span><span class="pl-c1">=</span><span class="pl-s">'object'</span>)

    <span class="pl-en">@<span class="pl-s1">classmethod</span></span>
    <span class="pl-k">def</span> <span class="pl-en">_concat_same_type</span>(<span class="pl-s1">cls</span>, <span class="pl-s1">to_concat</span>):
        <span class="pl-k">return</span> <span class="pl-en">cls</span>(<span class="pl-s1">np</span>.<span class="pl-en">concatenate</span>([<span class="pl-s1">array</span>.<span class="pl-s1">data</span> <span class="pl-k">for</span> <span class="pl-s1">array</span> <span class="pl-c1">in</span> <span class="pl-s1">to_concat</span>]))

    <span class="pl-k">def</span> <span class="pl-en">take_nd</span>(<span class="pl-s1">self</span>, <span class="pl-s1">indexer</span>, <span class="pl-s1">allow_fill</span><span class="pl-c1">=</span><span class="pl-c1">True</span>, <span class="pl-s1">fill_value</span><span class="pl-c1">=</span><span class="pl-c1">None</span>):
        <span class="pl-k">return</span> <span class="pl-s1">self</span>.<span class="pl-en">take</span>(<span class="pl-s1">indexer</span>, <span class="pl-s1">allow_fill</span><span class="pl-c1">=</span><span class="pl-s1">allow_fill</span>, <span class="pl-s1">fill_value</span><span class="pl-c1">=</span><span class="pl-s1">fill_value</span>)

    <span class="pl-k">def</span> <span class="pl-en">copy</span>(<span class="pl-s1">self</span>, <span class="pl-s1">deep</span><span class="pl-c1">=</span><span class="pl-c1">False</span>):
        <span class="pl-k">return</span> <span class="pl-en">type</span>(<span class="pl-s1">self</span>)(<span class="pl-s1">self</span>.<span class="pl-s1">data</span>.<span class="pl-en">copy</span>())

    <span class="pl-k">from</span> <span class="pl-s1">arcgis</span>.<span class="pl-s1">geometry</span> <span class="pl-k">import</span> <span class="pl-v">BaseGeometry</span>
    <span class="pl-en">@<span class="pl-s1">property</span></span>
    <span class="pl-k">def</span> <span class="pl-en">is_valid</span>(<span class="pl-s1">self</span>):
        <span class="pl-s">"""Checks if the Geometry is Valid"""</span>
        <span class="pl-k">return</span> <span class="pl-s1">pd</span>.<span class="pl-v">Series</span>([<span class="pl-s1">g</span>.<span class="pl-s1">is_valid</span> <span class="pl-k">for</span> <span class="pl-s1">g</span> <span class="pl-c1">in</span> <span class="pl-s1">self</span>])

<span class="pl-c">#### TO GET THE ERROR</span>
<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-s1">geoms</span> <span class="pl-c1">=</span> [{
  <span class="pl-s">"rings"</span> : [[[<span class="pl-c1">-</span><span class="pl-c1">97.06138</span>,<span class="pl-c1">32.837</span>],[<span class="pl-c1">-</span><span class="pl-c1">97.06133</span>,<span class="pl-c1">32.836</span>],[<span class="pl-c1">-</span><span class="pl-c1">97.06124</span>,<span class="pl-c1">32.834</span>],[<span class="pl-c1">-</span><span class="pl-c1">97.06127</span>,<span class="pl-c1">32.832</span>],
              [<span class="pl-c1">-</span><span class="pl-c1">97.06138</span>,<span class="pl-c1">32.837</span>]],[[<span class="pl-c1">-</span><span class="pl-c1">97.06326</span>,<span class="pl-c1">32.759</span>],[<span class="pl-c1">-</span><span class="pl-c1">97.06298</span>,<span class="pl-c1">32.755</span>],[<span class="pl-c1">-</span><span class="pl-c1">97.06153</span>,<span class="pl-c1">32.749</span>],
              [<span class="pl-c1">-</span><span class="pl-c1">97.06326</span>,<span class="pl-c1">32.759</span>]]],
  <span class="pl-s">"spatialReference"</span> : {<span class="pl-s">"wkid"</span> : <span class="pl-c1">4326</span>}
}
]
<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-s1">v</span> <span class="pl-c1">=</span> <span class="pl-v">GeoArray</span>(<span class="pl-s1">geoms</span>)
<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-s1">df</span> <span class="pl-c1">=</span> <span class="pl-s1">pd</span>.<span class="pl-v">DataFrame</span>({<span class="pl-s">"SHAPE"</span>: <span class="pl-s1">v</span>})
<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-s1">small</span> <span class="pl-c1">=</span> <span class="pl-s1">df</span>.<span class="pl-en">head</span>(<span class="pl-c1">1</span>)
<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-en">print</span>(<span class="pl-s1">small</span>)
</pre></div>
<h4 dir="auto">Problem description</h4>
<p dir="auto">Here is where the error occurs with I do a print(df.head(1))</p>
<p dir="auto"><code class="notranslate"> builtins.AttributeError: 'numpy.ndarray' object has no attribute '_formatting_values'</code></p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="    def formatting_values(self):
        return self.values._formatting_values()"><pre class="notranslate"><code class="notranslate">    def formatting_values(self):
        return self.values._formatting_values()
</code></pre></div>
<p dir="auto">I've implemented the override in the GeoArray, but it doesn't seem to ever get called instead it's calling the <code class="notranslate">_formatting_values()</code> on the <code class="notranslate">ExtensionBlock</code> class.</p>
<p dir="auto">Any suggestions on how to resolve this issue?</p>
<h4 dir="auto">Expected Output</h4>
<p dir="auto">A html version of the dataframe.</p>
<h4 dir="auto">Output of <code class="notranslate">pd.show_versions()</code></h4>
<details>
<p dir="auto">[paste the output of <code class="notranslate">pd.show_versions()</code> here below this line]</p>
<h2 dir="auto">INSTALLED VERSIONS</h2>
<p dir="auto">commit: None<br>
python: 3.6.5.final.0<br>
python-bits: 64<br>
OS: Windows<br>
OS-release: 10<br>
machine: AMD64<br>
processor: Intel64 Family 6 Model 94 Stepping 3, GenuineIntel<br>
byteorder: little<br>
LC_ALL: None<br>
LANG: None<br>
LOCALE: English_United States.1252</p>
<p dir="auto">pandas: 0.23.0<br>
pytest: 3.5.0<br>
pip: 9.0.3<br>
setuptools: 39.0.1<br>
Cython: None<br>
numpy: 1.14.2<br>
scipy: 1.0.1<br>
pyarrow: None<br>
xarray: None<br>
IPython: 6.3.1<br>
sphinx: None<br>
patsy: None<br>
dateutil: 2.7.2<br>
pytz: 2018.3<br>
blosc: None<br>
bottleneck: None<br>
tables: None<br>
numexpr: 2.6.4<br>
feather: None<br>
matplotlib: 2.2.2<br>
openpyxl: 2.5.2<br>
xlrd: 1.1.0<br>
xlwt: 1.3.0<br>
xlsxwriter: None<br>
lxml: None<br>
bs4: None<br>
html5lib: 1.0.1<br>
sqlalchemy: None<br>
pymysql: None<br>
psycopg2: None<br>
jinja2: 2.10<br>
s3fs: None<br>
fastparquet: None<br>
pandas_gbq: None<br>
pandas_datareader: None</p>
</details>