<p dir="auto">When trying to reindex with an index with duplicate values, I get the error message <code class="notranslate">ValueError: Shape of passed values is (1, 20), indices imply (1, 10)</code>, while I expected somthing like <code class="notranslate">Reindexing only valid with uniquely valued Index objects</code></p>
<p dir="auto">I see this with both 0.12 and master.</p>
<p dir="auto">An example:</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="In [2]: pd.__version__
Out[2]:  '0.12.0-274-gc472099'

In [3]: s = pd.DataFrame(np.random.randn(10), index=[1,2,3,4,5,1,2,3,4,5])

In [4]: s
Out[4]:
    0
1   -0.067753
2   -1.544545
3   0.726160
4   0.562298
5   -0.094550
1   0.753334
2   -0.893318
3   -0.275085
4   2.645206
5   -0.926170

In [5]:  s.reindex(index=range(len(s)))

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
&lt;ipython-input-6-2085c8b16fe3&gt; in &lt;module&gt;()
----&gt; 1 s.reindex(index=range(len(s)))

c:\users\vdbosscj\scipy\pandas-joris\pandas\core\generic.pyc in reindex(self, *args, **kwargs)
   1085 
   1086         # perform the reindex on the axes
-&gt; 1087         return self._reindex_axes(axes, level, limit, method, fill_value, copy, takeable=takeable)._propogate_attributes(self)
   1088 
   1089     def _reindex_axes(self, axes, level, limit, method, fill_value, copy, takeable=False):

c:\users\vdbosscj\scipy\pandas-joris\pandas\core\frame.pyc in _reindex_axes(self, axes, level, limit, method, fill_value, copy, takeable)
   2268         if index is not None:
   2269             frame = frame._reindex_index(index, method, copy, level,
-&gt; 2270                                          fill_value, limit, takeable=takeable)
   2271 
   2272         return frame

c:\users\vdbosscj\scipy\pandas-joris\pandas\core\frame.pyc in _reindex_index(self, new_index, method, copy, level, fill_value, limit, takeable)
   2278                                                 takeable=takeable)
   2279         return self._reindex_with_indexers({0: [new_index, indexer]},
-&gt; 2280                                            copy=copy, fill_value=fill_value)
   2281 
   2282     def _reindex_columns(self, new_columns, copy, level, fill_value=NA,

c:\users\vdbosscj\scipy\pandas-joris\pandas\core\generic.pyc in _reindex_with_indexers(self, reindexers, method, fill_value, limit, copy)
   1184                 indexer = com._ensure_int64(indexer)
   1185                 new_data = new_data.reindex_indexer(index, indexer, axis=baxis,
-&gt; 1186                                                     fill_value=fill_value)
   1187 
   1188             elif baxis == 0 and index is not None and index is not new_data.axes[baxis]:

c:\users\vdbosscj\scipy\pandas-joris\pandas\core\internals.pyc in reindex_indexer(self, new_axis, indexer, axis, fill_value)
   2673         new_axes = list(self.axes)
   2674         new_axes[axis] = new_axis
-&gt; 2675         return self.__class__(new_blocks, new_axes)
   2676 
   2677     def _reindex_indexer_items(self, new_items, indexer, fill_value):

c:\users\vdbosscj\scipy\pandas-joris\pandas\core\internals.pyc in __init__(self, blocks, axes, do_integrity_check, fastpath)
   1563 
   1564         if do_integrity_check:
-&gt; 1565             self._verify_integrity()
   1566 
   1567         self._has_sparse = False

c:\users\vdbosscj\scipy\pandas-joris\pandas\core\internals.pyc in _verify_integrity(self)
   1826             if not block.is_sparse and block.values.shape[1:] != mgr_shape[1:]:
   1827                 construction_error(
-&gt; 1828                     tot_items, block.values.shape[1:], self.axes)
   1829         if len(self.items) != tot_items:
   1830             raise AssertionError('Number of manager items must equal union of '

c:\users\vdbosscj\scipy\pandas-joris\pandas\core\internals.pyc in construction_error(tot_items, block_shape, axes)
   3063     raise ValueError(&quot;Shape of passed values is %s, indices imply %s&quot; % (
   3064         tuple(map(int, [tot_items] + list(block_shape))),
-&gt; 3065         tuple(map(int, [len(ax) for ax in axes]))))
   3066 
   3067 

ValueError: Shape of passed values is (1, 15), indices imply (1, 10)


In [6]:  s.reindex(index=s.index.order())

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
&lt;ipython-input-5-2ce611a93f5d&gt; in &lt;module&gt;()
----&gt; 1 s.reindex(index=s.index.order())

.....

c:\users\vdbosscj\scipy\pandas-joris\pandas\core\internals.py in construction_error(tot_items, block_shape, axes)
   3063     raise ValueError(&quot;Shape of passed values is %s, indices imply %s&quot; % (
   3064         tuple(map(int, [tot_items] + list(block_shape))),
-&gt; 3065         tuple(map(int, [len(ax) for ax in axes]))))
   3066 
   3067 

ValueError: Shape of passed values is (1, 20), indices imply (1, 10)
"><pre class="notranslate"><span class="pl-v">In</span> [<span class="pl-c1">2</span>]: <span class="pl-s1">pd</span>.<span class="pl-s1">__version__</span>
<span class="pl-v">Out</span>[<span class="pl-c1">2</span>]:  <span class="pl-s">'0.12.0-274-gc472099'</span>

<span class="pl-v">In</span> [<span class="pl-c1">3</span>]: <span class="pl-s1">s</span> <span class="pl-c1">=</span> <span class="pl-s1">pd</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">10</span>), <span class="pl-s1">index</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-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-v">In</span> [<span class="pl-c1">4</span>]: <span class="pl-s1">s</span>
<span class="pl-v">Out</span>[<span class="pl-c1">4</span>]:
    <span class="pl-c1">0</span>
<span class="pl-c1">1</span>   <span class="pl-c1">-</span><span class="pl-c1">0.067753</span>
<span class="pl-c1">2</span>   <span class="pl-c1">-</span><span class="pl-c1">1.544545</span>
<span class="pl-c1">3</span>   <span class="pl-c1">0.726160</span>
<span class="pl-c1">4</span>   <span class="pl-c1">0.562298</span>
<span class="pl-c1">5</span>   <span class="pl-c1">-</span><span class="pl-c1">0.094550</span>
<span class="pl-c1">1</span>   <span class="pl-c1">0.753334</span>
<span class="pl-c1">2</span>   <span class="pl-c1">-</span><span class="pl-c1">0.893318</span>
<span class="pl-c1">3</span>   <span class="pl-c1">-</span><span class="pl-c1">0.275085</span>
<span class="pl-c1">4</span>   <span class="pl-c1">2.645206</span>
<span class="pl-c1">5</span>   <span class="pl-c1">-</span><span class="pl-c1">0.926170</span>

<span class="pl-v">In</span> [<span class="pl-c1">5</span>]:  <span class="pl-s1">s</span>.<span class="pl-en">reindex</span>(<span class="pl-s1">index</span><span class="pl-c1">=</span><span class="pl-en">range</span>(<span class="pl-en">len</span>(<span class="pl-s1">s</span>)))

<span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span>
<span class="pl-v">ValueError</span>                                <span class="pl-v">Traceback</span> (<span class="pl-s1">most</span> <span class="pl-s1">recent</span> <span class="pl-s1">call</span> <span class="pl-s1">last</span>)
<span class="pl-c1">&lt;</span><span class="pl-s1">ipython</span><span class="pl-c1">-</span><span class="pl-s1">input</span><span class="pl-c1">-</span><span class="pl-c1">6</span><span class="pl-c1">-</span><span class="pl-c1">2085</span><span class="pl-s1">c8b16fe3</span><span class="pl-c1">&gt;</span> <span class="pl-s1">in</span> <span class="pl-c1">&lt;</span><span class="pl-s1">module</span><span class="pl-c1">&gt;</span>()
<span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">&gt;</span> <span class="pl-c1">1</span> <span class="pl-s1">s</span>.<span class="pl-en">reindex</span>(<span class="pl-s1">index</span><span class="pl-c1">=</span><span class="pl-en">range</span>(<span class="pl-en">len</span>(<span class="pl-s1">s</span>)))

<span class="pl-s1">c</span>:\u<span class="pl-s1">sers</span>\v<span class="pl-s1">dbosscj</span>\s<span class="pl-s1">cipy</span>\p<span class="pl-s1">andas</span><span class="pl-c1">-</span><span class="pl-s1">joris</span>\p<span class="pl-s1">andas</span>\c<span class="pl-s1">ore</span>\g<span class="pl-s1">eneric</span>.<span class="pl-s1">pyc</span> <span class="pl-c1">in</span> <span class="pl-en">reindex</span>(<span class="pl-s1">self</span>, <span class="pl-c1">*</span><span class="pl-s1">args</span>, <span class="pl-c1">**</span><span class="pl-s1">kwargs</span>)
   <span class="pl-c1">1085</span> 
   <span class="pl-c1">1086</span>         <span class="pl-c"># perform the reindex on the axes</span>
<span class="pl-c1">-</span><span class="pl-c1">&gt;</span> <span class="pl-c1">1087</span>         <span class="pl-s1">return</span> <span class="pl-s1">self</span>.<span class="pl-en">_reindex_axes</span>(<span class="pl-s1">axes</span>, <span class="pl-s1">level</span>, <span class="pl-s1">limit</span>, <span class="pl-s1">method</span>, <span class="pl-s1">fill_value</span>, <span class="pl-s1">copy</span>, <span class="pl-s1">takeable</span><span class="pl-c1">=</span><span class="pl-s1">takeable</span>).<span class="pl-en">_propogate_attributes</span>(<span class="pl-s1">self</span>)
   <span class="pl-c1">1088</span> 
   <span class="pl-c1">1089</span>     <span class="pl-k">def</span> <span class="pl-en">_reindex_axes</span>(<span class="pl-s1">self</span>, <span class="pl-s1">axes</span>, <span class="pl-s1">level</span>, <span class="pl-s1">limit</span>, <span class="pl-s1">method</span>, <span class="pl-s1">fill_value</span>, <span class="pl-s1">copy</span>, <span class="pl-s1">takeable</span><span class="pl-c1">=</span><span class="pl-c1">False</span>):

<span class="pl-s1">c</span>:\u<span class="pl-s1">sers</span>\v<span class="pl-s1">dbosscj</span>\s<span class="pl-s1">cipy</span>\p<span class="pl-s1">andas</span><span class="pl-c1">-</span><span class="pl-s1">joris</span>\p<span class="pl-s1">andas</span>\c<span class="pl-s1">ore</span>\f<span class="pl-s1">rame</span>.<span class="pl-s1">pyc</span> <span class="pl-c1">in</span> <span class="pl-en">_reindex_axes</span>(<span class="pl-s1">self</span>, <span class="pl-s1">axes</span>, <span class="pl-s1">level</span>, <span class="pl-s1">limit</span>, <span class="pl-s1">method</span>, <span class="pl-s1">fill_value</span>, <span class="pl-s1">copy</span>, <span class="pl-s1">takeable</span>)
   <span class="pl-c1">2268</span>         <span class="pl-k">if</span> <span class="pl-s1">index</span> <span class="pl-c1">is</span> <span class="pl-c1">not</span> <span class="pl-c1">None</span>:
   <span class="pl-c1">2269</span>             <span class="pl-s1">frame</span> <span class="pl-c1">=</span> <span class="pl-s1">frame</span>.<span class="pl-en">_reindex_index</span>(<span class="pl-s1">index</span>, <span class="pl-s1">method</span>, <span class="pl-s1">copy</span>, <span class="pl-s1">level</span>,
<span class="pl-c1">-</span><span class="pl-c1">&gt;</span> <span class="pl-c1">2270</span>                                          <span class="pl-s1">fill_value</span>, <span class="pl-s1">limit</span>, <span class="pl-s1">takeable</span><span class="pl-c1">=</span><span class="pl-s1">takeable</span>)
   <span class="pl-c1">2271</span> 
   <span class="pl-c1">2272</span>         <span class="pl-s1">return</span> <span class="pl-s1">frame</span>

<span class="pl-s1">c</span>:\u<span class="pl-s1">sers</span>\v<span class="pl-s1">dbosscj</span>\s<span class="pl-s1">cipy</span>\p<span class="pl-s1">andas</span><span class="pl-c1">-</span><span class="pl-s1">joris</span>\p<span class="pl-s1">andas</span>\c<span class="pl-s1">ore</span>\f<span class="pl-s1">rame</span>.<span class="pl-s1">pyc</span> <span class="pl-c1">in</span> <span class="pl-en">_reindex_index</span>(<span class="pl-s1">self</span>, <span class="pl-s1">new_index</span>, <span class="pl-s1">method</span>, <span class="pl-s1">copy</span>, <span class="pl-s1">level</span>, <span class="pl-s1">fill_value</span>, <span class="pl-s1">limit</span>, <span class="pl-s1">takeable</span>)
   <span class="pl-c1">2278</span>                                                 <span class="pl-s1">takeable</span><span class="pl-c1">=</span><span class="pl-s1">takeable</span>)
   <span class="pl-c1">2279</span>         <span class="pl-k">return</span> <span class="pl-s1">self</span>.<span class="pl-en">_reindex_with_indexers</span>({<span class="pl-c1">0</span>: [<span class="pl-s1">new_index</span>, <span class="pl-s1">indexer</span>]},
<span class="pl-c1">-</span><span class="pl-c1">&gt;</span> <span class="pl-c1">2280</span>                                            <span class="pl-s1">copy</span><span class="pl-c1">=</span><span class="pl-s1">copy</span>, <span class="pl-s1">fill_value</span><span class="pl-c1">=</span><span class="pl-s1">fill_value</span>)
   <span class="pl-c1">2281</span> 
   <span class="pl-c1">2282</span>     <span class="pl-s1">def</span> <span class="pl-s1">_reindex_columns</span>(<span class="pl-s1">self</span>, <span class="pl-s1">new_columns</span>, <span class="pl-s1">copy</span>, <span class="pl-s1">level</span>, <span class="pl-s1">fill_value</span><span class="pl-c1">=</span><span class="pl-v">NA</span>,

<span class="pl-s1">c</span>:\u<span class="pl-s1">sers</span>\v<span class="pl-s1">dbosscj</span>\s<span class="pl-s1">cipy</span>\p<span class="pl-s1">andas</span><span class="pl-c1">-</span><span class="pl-s1">joris</span>\p<span class="pl-s1">andas</span>\c<span class="pl-s1">ore</span>\g<span class="pl-s1">eneric</span>.<span class="pl-s1">pyc</span> <span class="pl-c1">in</span> <span class="pl-en">_reindex_with_indexers</span>(<span class="pl-s1">self</span>, <span class="pl-s1">reindexers</span>, <span class="pl-s1">method</span>, <span class="pl-s1">fill_value</span>, <span class="pl-s1">limit</span>, <span class="pl-s1">copy</span>)
   <span class="pl-c1">1184</span>                 <span class="pl-s1">indexer</span> <span class="pl-c1">=</span> <span class="pl-s1">com</span>.<span class="pl-en">_ensure_int64</span>(<span class="pl-s1">indexer</span>)
   <span class="pl-c1">1185</span>                 <span class="pl-s1">new_data</span> <span class="pl-c1">=</span> <span class="pl-s1">new_data</span>.<span class="pl-en">reindex_indexer</span>(<span class="pl-s1">index</span>, <span class="pl-s1">indexer</span>, <span class="pl-s1">axis</span><span class="pl-c1">=</span><span class="pl-s1">baxis</span>,
<span class="pl-c1">-</span><span class="pl-c1">&gt;</span> <span class="pl-c1">1186</span>                                                     <span class="pl-s1">fill_value</span><span class="pl-c1">=</span><span class="pl-s1">fill_value</span>)
   <span class="pl-c1">1187</span> 
   <span class="pl-c1">1188</span>             <span class="pl-k">elif</span> <span class="pl-s1">baxis</span> <span class="pl-c1">==</span> <span class="pl-c1">0</span> <span class="pl-c1">and</span> <span class="pl-s1">index</span> <span class="pl-c1">is</span> <span class="pl-c1">not</span> <span class="pl-c1">None</span> <span class="pl-c1">and</span> <span class="pl-s1">index</span> <span class="pl-c1">is</span> <span class="pl-c1">not</span> <span class="pl-s1">new_data</span>.<span class="pl-s1">axes</span>[<span class="pl-s1">baxis</span>]:

<span class="pl-s1">c</span>:\u<span class="pl-s1">sers</span>\v<span class="pl-s1">dbosscj</span>\s<span class="pl-s1">cipy</span>\p<span class="pl-s1">andas</span><span class="pl-c1">-</span><span class="pl-s1">joris</span>\p<span class="pl-s1">andas</span>\c<span class="pl-s1">ore</span>\i<span class="pl-s1">nternals</span>.<span class="pl-s1">pyc</span> <span class="pl-c1">in</span> <span class="pl-en">reindex_indexer</span>(<span class="pl-s1">self</span>, <span class="pl-s1">new_axis</span>, <span class="pl-s1">indexer</span>, <span class="pl-s1">axis</span>, <span class="pl-s1">fill_value</span>)
   <span class="pl-c1">2673</span>         <span class="pl-s1">new_axes</span> <span class="pl-c1">=</span> <span class="pl-s1">list</span>(<span class="pl-s1">self</span>.<span class="pl-s1">axes</span>)
   <span class="pl-c1">2674</span>         <span class="pl-s1">new_axes</span>[<span class="pl-s1">axis</span>] <span class="pl-c1">=</span> <span class="pl-s1">new_axis</span>
<span class="pl-c1">-</span><span class="pl-c1">&gt;</span> <span class="pl-c1">2675</span>         <span class="pl-s1">return</span> <span class="pl-s1">self</span>.<span class="pl-en">__class__</span>(<span class="pl-s1">new_blocks</span>, <span class="pl-s1">new_axes</span>)
   <span class="pl-c1">2676</span> 
   <span class="pl-c1">2677</span>     <span class="pl-s1">def</span> <span class="pl-en">_reindex_indexer_items</span>(<span class="pl-s1">self</span>, <span class="pl-s1">new_items</span>, <span class="pl-s1">indexer</span>, <span class="pl-s1">fill_value</span>):

<span class="pl-s1">c</span>:\u<span class="pl-s1">sers</span>\v<span class="pl-s1">dbosscj</span>\s<span class="pl-s1">cipy</span>\p<span class="pl-s1">andas</span><span class="pl-c1">-</span><span class="pl-s1">joris</span>\p<span class="pl-s1">andas</span>\c<span class="pl-s1">ore</span>\i<span class="pl-s1">nternals</span>.<span class="pl-s1">pyc</span> <span class="pl-c1">in</span> <span class="pl-en">__init__</span>(<span class="pl-s1">self</span>, <span class="pl-s1">blocks</span>, <span class="pl-s1">axes</span>, <span class="pl-s1">do_integrity_check</span>, <span class="pl-s1">fastpath</span>)
   <span class="pl-c1">1563</span> 
   <span class="pl-c1">1564</span>         <span class="pl-k">if</span> <span class="pl-s1">do_integrity_check</span>:
<span class="pl-c1">-&gt;</span> <span class="pl-c1">1565</span>             <span class="pl-s1">self</span>.<span class="pl-en">_verify_integrity</span>()
   <span class="pl-c1">1566</span> 
   <span class="pl-c1">1567</span>         <span class="pl-s1">self</span>.<span class="pl-s1">_has_sparse</span> <span class="pl-c1">=</span> <span class="pl-c1">False</span>

<span class="pl-s1">c</span>:\u<span class="pl-s1">sers</span>\v<span class="pl-s1">dbosscj</span>\s<span class="pl-s1">cipy</span>\p<span class="pl-s1">andas</span><span class="pl-c1">-</span><span class="pl-s1">joris</span>\p<span class="pl-s1">andas</span>\c<span class="pl-s1">ore</span>\i<span class="pl-s1">nternals</span>.<span class="pl-s1">pyc</span> <span class="pl-c1">in</span> <span class="pl-en">_verify_integrity</span>(<span class="pl-s1">self</span>)
   <span class="pl-c1">1826</span>             <span class="pl-k">if</span> <span class="pl-c1">not</span> <span class="pl-s1">block</span>.<span class="pl-s1">is_sparse</span> <span class="pl-c1">and</span> <span class="pl-s1">block</span>.<span class="pl-s1">values</span>.<span class="pl-s1">shape</span>[<span class="pl-c1">1</span>:] <span class="pl-c1">!=</span> <span class="pl-s1">mgr_shape</span>[<span class="pl-c1">1</span>:]:
   <span class="pl-c1">1827</span>                 <span class="pl-en">construction_error</span>(
<span class="pl-c1">-</span><span class="pl-c1">&gt;</span> <span class="pl-c1">1828</span>                     <span class="pl-s1">tot_items</span>, <span class="pl-s1">block</span>.<span class="pl-s1">values</span>.<span class="pl-s1">shape</span>[<span class="pl-c1">1</span>:], <span class="pl-s1">self</span>.<span class="pl-s1">axes</span>)
   <span class="pl-c1">1829</span>         <span class="pl-k">if</span> <span class="pl-en">len</span>(<span class="pl-s1">self</span>.<span class="pl-s1">items</span>) <span class="pl-c1">!=</span> <span class="pl-s1">tot_items</span>:
   <span class="pl-c1">1830</span>             <span class="pl-s1">raise</span> <span class="pl-v">AssertionError</span>(<span class="pl-s">'Number of manager items must equal union of '</span>

<span class="pl-s1">c</span>:\u<span class="pl-s1">sers</span>\v<span class="pl-s1">dbosscj</span>\s<span class="pl-s1">cipy</span>\p<span class="pl-s1">andas</span><span class="pl-c1">-</span><span class="pl-s1">joris</span>\p<span class="pl-s1">andas</span>\c<span class="pl-s1">ore</span>\i<span class="pl-s1">nternals</span>.<span class="pl-s1">pyc</span> <span class="pl-c1">in</span> <span class="pl-en">construction_error</span>(<span class="pl-s1">tot_items</span>, <span class="pl-s1">block_shape</span>, <span class="pl-s1">axes</span>)
   <span class="pl-c1">3063</span>     <span class="pl-k">raise</span> <span class="pl-v">ValueError</span>(<span class="pl-s">"Shape of passed values is %s, indices imply %s"</span> <span class="pl-c1">%</span> (
   <span class="pl-c1">3064</span>         <span class="pl-en">tuple</span>(<span class="pl-en">map</span>(<span class="pl-s1">int</span>, [<span class="pl-s1">tot_items</span>] <span class="pl-c1">+</span> <span class="pl-en">list</span>(<span class="pl-s1">block_shape</span>))),
<span class="pl-c1">-</span><span class="pl-c1">&gt;</span> <span class="pl-c1">3065</span>         <span class="pl-en">tuple</span>(<span class="pl-en">map</span>(<span class="pl-s1">int</span>, [<span class="pl-en">len</span>(<span class="pl-s1">ax</span>) <span class="pl-k">for</span> <span class="pl-s1">ax</span> <span class="pl-c1">in</span> <span class="pl-s1">axes</span>]))))
   <span class="pl-c1">3066</span> 
   <span class="pl-c1">3067</span> 

<span class="pl-v">ValueError</span>: <span class="pl-v">Shape</span> <span class="pl-s1">of</span> <span class="pl-s1">passed</span> <span class="pl-s1">values</span> <span class="pl-c1">is</span> (<span class="pl-c1">1</span>, <span class="pl-c1">15</span>), <span class="pl-en">indices</span> <span class="pl-s1">imply</span> (<span class="pl-c1">1</span>, <span class="pl-c1">10</span>)


<span class="pl-v">In</span> [<span class="pl-c1">6</span>]:  <span class="pl-s1">s</span>.<span class="pl-en">reindex</span>(<span class="pl-s1">index</span><span class="pl-c1">=</span><span class="pl-s1">s</span>.<span class="pl-s1">index</span>.<span class="pl-en">order</span>())

<span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span>
<span class="pl-v">ValueError</span>                                <span class="pl-v">Traceback</span> (<span class="pl-s1">most</span> <span class="pl-s1">recent</span> <span class="pl-s1">call</span> <span class="pl-s1">last</span>)
<span class="pl-c1">&lt;</span><span class="pl-s1">ipython</span><span class="pl-c1">-</span><span class="pl-s1">input</span><span class="pl-c1">-</span><span class="pl-c1">5</span><span class="pl-c1">-</span><span class="pl-c1">2</span><span class="pl-s1">ce611a93f5d</span><span class="pl-c1">&gt;</span> <span class="pl-s1">in</span> <span class="pl-c1">&lt;</span><span class="pl-s1">module</span><span class="pl-c1">&gt;</span>()
<span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">&gt;</span> <span class="pl-c1">1</span> <span class="pl-s1">s</span>.<span class="pl-en">reindex</span>(<span class="pl-s1">index</span><span class="pl-c1">=</span><span class="pl-s1">s</span>.<span class="pl-s1">index</span>.<span class="pl-en">order</span>())

.....

<span class="pl-s1">c</span>:\u<span class="pl-s1">sers</span>\v<span class="pl-s1">dbosscj</span>\s<span class="pl-s1">cipy</span>\p<span class="pl-s1">andas</span><span class="pl-c1">-</span><span class="pl-s1">joris</span>\p<span class="pl-s1">andas</span>\c<span class="pl-s1">ore</span>\i<span class="pl-s1">nternals</span>.<span class="pl-s1">py</span> <span class="pl-c1">in</span> <span class="pl-en">construction_error</span>(<span class="pl-s1">tot_items</span>, <span class="pl-s1">block_shape</span>, <span class="pl-s1">axes</span>)
   <span class="pl-c1">3063</span>     <span class="pl-k">raise</span> <span class="pl-v">ValueError</span>(<span class="pl-s">"Shape of passed values is %s, indices imply %s"</span> <span class="pl-c1">%</span> (
   <span class="pl-c1">3064</span>         <span class="pl-en">tuple</span>(<span class="pl-en">map</span>(<span class="pl-s1">int</span>, [<span class="pl-s1">tot_items</span>] <span class="pl-c1">+</span> <span class="pl-en">list</span>(<span class="pl-s1">block_shape</span>))),
<span class="pl-c1">-</span><span class="pl-c1">&gt;</span> <span class="pl-c1">3065</span>         <span class="pl-en">tuple</span>(<span class="pl-en">map</span>(<span class="pl-s1">int</span>, [<span class="pl-en">len</span>(<span class="pl-s1">ax</span>) <span class="pl-k">for</span> <span class="pl-s1">ax</span> <span class="pl-c1">in</span> <span class="pl-s1">axes</span>]))))
   <span class="pl-c1">3066</span> 
   <span class="pl-c1">3067</span> 

<span class="pl-v">ValueError</span>: <span class="pl-v">Shape</span> <span class="pl-s1">of</span> <span class="pl-s1">passed</span> <span class="pl-s1">values</span> <span class="pl-c1">is</span> (<span class="pl-c1">1</span>, <span class="pl-c1">20</span>), <span class="pl-en">indices</span> <span class="pl-s1">imply</span> (<span class="pl-c1">1</span>, <span class="pl-c1">10</span>)</pre></div>
<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="In [1]: import pandas as pd
   ...: 
   ...: def check_roundtrip(obj):
   ...:     with pd.HDFStore('test.h5', 'w') as store:
   ...:         store['obj'] = obj
   ...:         retrieved = store['obj']
   ...:         return obj.equals(retrieved)
   ...: 
   ...: s = pd.Series([], dtype='datetime64[ns, UTC]')
   ...: t = pd.Series([0], dtype='datetime64[ns, UTC]')
   ...: df = pd.DataFrame({'A': s})

In [2]: print(check_roundtrip(s))
False

In [3]: print(check_roundtrip(t))
False

In [4]: print(check_roundtrip(df))

------------------------------------------------------------------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
&lt;ipython-input-4-57f1e9853bf6&gt; in &lt;module&gt;()
----&gt; 1 print(check_roundtrip(df))

&lt;ipython-input-1-1d7fb84453e9&gt; in check_roundtrip(obj)
      4     with pd.HDFStore('test.h5', 'w') as store:
      5         store['obj'] = obj
----&gt; 6         retrieved = store['obj']
      7         return obj.equals(retrieved)
      8 

/home/ashieh/.local/lib/python2.7/site-packages/pandas/io/pytables.pyc in __getitem__(self, key)
    481 
    482     def __getitem__(self, key):
--&gt; 483         return self.get(key)
    484 
    485     def __setitem__(self, key, value):

/home/ashieh/.local/lib/python2.7/site-packages/pandas/io/pytables.pyc in get(self, key)
    669         if group is None:
    670             raise KeyError('No object named %s in the file' % key)
--&gt; 671         return self._read_group(group)
    672 
    673     def select(self, key, where=None, start=None, stop=None, columns=None,

/home/ashieh/.local/lib/python2.7/site-packages/pandas/io/pytables.pyc in _read_group(self, group, **kwargs)
   1347         s = self._create_storer(group)
   1348         s.infer_axes()
-&gt; 1349         return s.read(**kwargs)
   1350 
   1351 

/home/ashieh/.local/lib/python2.7/site-packages/pandas/io/pytables.pyc in read(self, start, stop, **kwargs)
   2902             blk_items = self.read_index('block%d_items' % i)
   2903             values = self.read_array('block%d_values' % i,
-&gt; 2904                                      start=_start, stop=_stop)
   2905             blk = make_block(values,
   2906                              placement=items.get_indexer(blk_items))

/home/ashieh/.local/lib/python2.7/site-packages/pandas/io/pytables.pyc in read_array(self, key, start, stop)
   2464             if shape is not None:
   2465                 # length 0 axis
-&gt; 2466                 ret = np.empty(shape, dtype=dtype)
   2467             else:
   2468                 ret = node[start:stop]

TypeError: Invalid datetime unit in metadata string &quot;[ns, UTC]&quot;"><pre class="notranslate"><span class="pl-v">In</span> [<span class="pl-c1">1</span>]: <span class="pl-s1">import</span> <span class="pl-s1">pandas</span> <span class="pl-k">as</span> <span class="pl-s1">pd</span>
   ...: 
   ...: <span class="pl-k">def</span> <span class="pl-en">check_roundtrip</span>(<span class="pl-s1">obj</span>):
   ...:     <span class="pl-k">with</span> <span class="pl-s1">pd</span>.<span class="pl-v">HDFStore</span>(<span class="pl-s">'test.h5'</span>, <span class="pl-s">'w'</span>) <span class="pl-k">as</span> <span class="pl-s1">store</span>:
   ...:         <span class="pl-s1">store</span>[<span class="pl-s">'obj'</span>] <span class="pl-c1">=</span> <span class="pl-s1">obj</span>
   ...:         <span class="pl-s1">retrieved</span> <span class="pl-c1">=</span> <span class="pl-s1">store</span>[<span class="pl-s">'obj'</span>]
   ...:         <span class="pl-k">return</span> <span class="pl-s1">obj</span>.<span class="pl-en">equals</span>(<span class="pl-s1">retrieved</span>)
   ...: 
   ...: <span class="pl-s1">s</span> <span class="pl-c1">=</span> <span class="pl-s1">pd</span>.<span class="pl-v">Series</span>([], <span class="pl-s1">dtype</span><span class="pl-c1">=</span><span class="pl-s">'datetime64[ns, UTC]'</span>)
   ...: <span class="pl-s1">t</span> <span class="pl-c1">=</span> <span class="pl-s1">pd</span>.<span class="pl-v">Series</span>([<span class="pl-c1">0</span>], <span class="pl-s1">dtype</span><span class="pl-c1">=</span><span class="pl-s">'datetime64[ns, UTC]'</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">'A'</span>: <span class="pl-s1">s</span>})

<span class="pl-v">In</span> [<span class="pl-c1">2</span>]: <span class="pl-en">print</span>(<span class="pl-en">check_roundtrip</span>(<span class="pl-s1">s</span>))
<span class="pl-c1">False</span>

<span class="pl-v">In</span> [<span class="pl-c1">3</span>]: <span class="pl-en">print</span>(<span class="pl-en">check_roundtrip</span>(<span class="pl-s1">t</span>))
<span class="pl-c1">False</span>

<span class="pl-v">In</span> [<span class="pl-c1">4</span>]: <span class="pl-en">print</span>(<span class="pl-en">check_roundtrip</span>(<span class="pl-s1">df</span>))

<span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span>
<span class="pl-v">TypeError</span>                                 <span class="pl-v">Traceback</span> (<span class="pl-s1">most</span> <span class="pl-s1">recent</span> <span class="pl-s1">call</span> <span class="pl-s1">last</span>)
<span class="pl-c1">&lt;</span><span class="pl-s1">ipython</span><span class="pl-c1">-</span><span class="pl-s1">input</span><span class="pl-c1">-</span><span class="pl-c1">4</span><span class="pl-c1">-</span><span class="pl-c1">57</span><span class="pl-s1">f1e9853bf6</span><span class="pl-c1">&gt;</span> <span class="pl-s1">in</span> <span class="pl-c1">&lt;</span><span class="pl-s1">module</span><span class="pl-c1">&gt;</span>()
<span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">&gt;</span> <span class="pl-c1">1</span> <span class="pl-en">print</span>(<span class="pl-en">check_roundtrip</span>(<span class="pl-s1">df</span>))

<span class="pl-c1">&lt;</span><span class="pl-s1">ipython</span><span class="pl-c1">-</span><span class="pl-s1">input</span><span class="pl-c1">-</span><span class="pl-c1">1</span><span class="pl-c1">-</span><span class="pl-c1">1</span><span class="pl-s1">d7fb84453e9</span><span class="pl-c1">&gt;</span> <span class="pl-s1">in</span> <span class="pl-en">check_roundtrip</span>(<span class="pl-s1">obj</span>)
      <span class="pl-c1">4</span>     <span class="pl-k">with</span> <span class="pl-s1">pd</span>.<span class="pl-v">HDFStore</span>(<span class="pl-s">'test.h5'</span>, <span class="pl-s">'w'</span>) <span class="pl-k">as</span> <span class="pl-s1">store</span>:
      <span class="pl-c1">5</span>         <span class="pl-s1">store</span>[<span class="pl-s">'obj'</span>] <span class="pl-c1">=</span> <span class="pl-s1">obj</span>
<span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">&gt;</span> <span class="pl-c1">6</span>         <span class="pl-s1">retrieved</span> <span class="pl-c1">=</span> <span class="pl-s1">store</span>[<span class="pl-s">'obj'</span>]
      <span class="pl-c1">7</span>         <span class="pl-k">return</span> <span class="pl-s1">obj</span>.<span class="pl-en">equals</span>(<span class="pl-s1">retrieved</span>)
      <span class="pl-c1">8</span> 

<span class="pl-c1">/</span><span class="pl-s1">home</span><span class="pl-c1">/</span><span class="pl-s1">ashieh</span><span class="pl-c1">/</span>.<span class="pl-s1">local</span><span class="pl-c1">/</span><span class="pl-s1">lib</span><span class="pl-c1">/</span><span class="pl-s1">python2</span>.<span class="pl-c1">7</span><span class="pl-c1">/</span><span class="pl-s1">site</span><span class="pl-c1">-</span><span class="pl-s1">packages</span><span class="pl-c1">/</span><span class="pl-s1">pandas</span><span class="pl-c1">/</span><span class="pl-s1">io</span><span class="pl-c1">/</span><span class="pl-s1">pytables</span>.<span class="pl-s1">pyc</span> <span class="pl-c1">in</span> <span class="pl-en">__getitem__</span>(<span class="pl-s1">self</span>, <span class="pl-s1">key</span>)
    <span class="pl-c1">481</span> 
    <span class="pl-c1">482</span>     <span class="pl-k">def</span> <span class="pl-en">__getitem__</span>(<span class="pl-s1">self</span>, <span class="pl-s1">key</span>):
<span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">&gt;</span> <span class="pl-c1">483</span>         <span class="pl-s1">return</span> <span class="pl-s1">self</span>.<span class="pl-en">get</span>(<span class="pl-s1">key</span>)
    <span class="pl-c1">484</span> 
    <span class="pl-c1">485</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-c1">/</span><span class="pl-s1">home</span><span class="pl-c1">/</span><span class="pl-s1">ashieh</span><span class="pl-c1">/</span>.<span class="pl-s1">local</span><span class="pl-c1">/</span><span class="pl-s1">lib</span><span class="pl-c1">/</span><span class="pl-s1">python2</span>.<span class="pl-c1">7</span><span class="pl-c1">/</span><span class="pl-s1">site</span><span class="pl-c1">-</span><span class="pl-s1">packages</span><span class="pl-c1">/</span><span class="pl-s1">pandas</span><span class="pl-c1">/</span><span class="pl-s1">io</span><span class="pl-c1">/</span><span class="pl-s1">pytables</span>.<span class="pl-s1">pyc</span> <span class="pl-c1">in</span> <span class="pl-en">get</span>(<span class="pl-s1">self</span>, <span class="pl-s1">key</span>)
    <span class="pl-c1">669</span>         <span class="pl-k">if</span> <span class="pl-s1">group</span> <span class="pl-c1">is</span> <span class="pl-c1">None</span>:
    <span class="pl-c1">670</span>             <span class="pl-s1">raise</span> <span class="pl-v">KeyError</span>(<span class="pl-s">'No object named %s in the file'</span> <span class="pl-c1">%</span> <span class="pl-s1">key</span>)
<span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">&gt;</span> <span class="pl-c1">671</span>         <span class="pl-s1">return</span> <span class="pl-s1">self</span>.<span class="pl-en">_read_group</span>(<span class="pl-s1">group</span>)
    <span class="pl-c1">672</span> 
    <span class="pl-c1">673</span>     <span class="pl-s1">def</span> <span class="pl-s1">select</span>(<span class="pl-s1">self</span>, <span class="pl-s1">key</span>, <span class="pl-s1">where</span><span class="pl-c1">=</span><span class="pl-c1">None</span>, <span class="pl-s1">start</span><span class="pl-c1">=</span><span class="pl-c1">None</span>, <span class="pl-s1">stop</span><span class="pl-c1">=</span><span class="pl-c1">None</span>, <span class="pl-s1">columns</span><span class="pl-c1">=</span><span class="pl-c1">None</span>,

<span class="pl-c1">/</span><span class="pl-s1">home</span><span class="pl-c1">/</span><span class="pl-s1">ashieh</span><span class="pl-c1">/</span>.<span class="pl-s1">local</span><span class="pl-c1">/</span><span class="pl-s1">lib</span><span class="pl-c1">/</span><span class="pl-s1">python2</span>.<span class="pl-c1">7</span><span class="pl-c1">/</span><span class="pl-s1">site</span><span class="pl-c1">-</span><span class="pl-s1">packages</span><span class="pl-c1">/</span><span class="pl-s1">pandas</span><span class="pl-c1">/</span><span class="pl-s1">io</span><span class="pl-c1">/</span><span class="pl-s1">pytables</span>.<span class="pl-s1">pyc</span> <span class="pl-c1">in</span> <span class="pl-en">_read_group</span>(<span class="pl-s1">self</span>, <span class="pl-s1">group</span>, <span class="pl-c1">**</span><span class="pl-s1">kwargs</span>)
   <span class="pl-c1">1347</span>         <span class="pl-s1">s</span> <span class="pl-c1">=</span> <span class="pl-s1">self</span>.<span class="pl-en">_create_storer</span>(<span class="pl-s1">group</span>)
   <span class="pl-c1">1348</span>         <span class="pl-s1">s</span>.<span class="pl-en">infer_axes</span>()
<span class="pl-c1">-</span><span class="pl-c1">&gt;</span> <span class="pl-c1">1349</span>         <span class="pl-s1">return</span> <span class="pl-s1">s</span>.<span class="pl-en">read</span>(<span class="pl-c1">**</span><span class="pl-s1">kwargs</span>)
   <span class="pl-c1">1350</span> 
   <span class="pl-c1">1351</span> 

<span class="pl-c1">/</span><span class="pl-s1">home</span><span class="pl-c1">/</span><span class="pl-s1">ashieh</span><span class="pl-c1">/</span>.<span class="pl-s1">local</span><span class="pl-c1">/</span><span class="pl-s1">lib</span><span class="pl-c1">/</span><span class="pl-s1">python2</span>.<span class="pl-c1">7</span><span class="pl-c1">/</span><span class="pl-s1">site</span><span class="pl-c1">-</span><span class="pl-s1">packages</span><span class="pl-c1">/</span><span class="pl-s1">pandas</span><span class="pl-c1">/</span><span class="pl-s1">io</span><span class="pl-c1">/</span><span class="pl-s1">pytables</span>.<span class="pl-s1">pyc</span> <span class="pl-c1">in</span> <span class="pl-en">read</span>(<span class="pl-s1">self</span>, <span class="pl-s1">start</span>, <span class="pl-s1">stop</span>, <span class="pl-c1">**</span><span class="pl-s1">kwargs</span>)
   <span class="pl-c1">2902</span>             <span class="pl-s1">blk_items</span> <span class="pl-c1">=</span> <span class="pl-s1">self</span>.<span class="pl-en">read_index</span>(<span class="pl-s">'block%d_items'</span> <span class="pl-c1">%</span> <span class="pl-s1">i</span>)
   <span class="pl-c1">2903</span>             <span class="pl-s1">values</span> <span class="pl-c1">=</span> <span class="pl-s1">self</span>.<span class="pl-en">read_array</span>(<span class="pl-s">'block%d_values'</span> <span class="pl-c1">%</span> <span class="pl-s1">i</span>,
<span class="pl-c1">-</span><span class="pl-c1">&gt;</span> <span class="pl-c1">2904</span>                                      <span class="pl-s1">start</span><span class="pl-c1">=</span><span class="pl-s1">_start</span>, <span class="pl-s1">stop</span><span class="pl-c1">=</span><span class="pl-s1">_stop</span>)
   <span class="pl-c1">2905</span>             <span class="pl-s1">blk</span> <span class="pl-c1">=</span> <span class="pl-en">make_block</span>(<span class="pl-s1">values</span>,
   <span class="pl-c1">2906</span>                              <span class="pl-s1">placement</span><span class="pl-c1">=</span><span class="pl-s1">items</span>.<span class="pl-en">get_indexer</span>(<span class="pl-s1">blk_items</span>))

<span class="pl-c1">/</span><span class="pl-s1">home</span><span class="pl-c1">/</span><span class="pl-s1">ashieh</span><span class="pl-c1">/</span>.<span class="pl-s1">local</span><span class="pl-c1">/</span><span class="pl-s1">lib</span><span class="pl-c1">/</span><span class="pl-s1">python2</span>.<span class="pl-c1">7</span><span class="pl-c1">/</span><span class="pl-s1">site</span><span class="pl-c1">-</span><span class="pl-s1">packages</span><span class="pl-c1">/</span><span class="pl-s1">pandas</span><span class="pl-c1">/</span><span class="pl-s1">io</span><span class="pl-c1">/</span><span class="pl-s1">pytables</span>.<span class="pl-s1">pyc</span> <span class="pl-c1">in</span> <span class="pl-en">read_array</span>(<span class="pl-s1">self</span>, <span class="pl-s1">key</span>, <span class="pl-s1">start</span>, <span class="pl-s1">stop</span>)
   <span class="pl-c1">2464</span>             <span class="pl-k">if</span> <span class="pl-s1">shape</span> <span class="pl-c1">is</span> <span class="pl-c1">not</span> <span class="pl-c1">None</span>:
   <span class="pl-c1">2465</span>                 <span class="pl-c"># length 0 axis</span>
<span class="pl-c1">-</span><span class="pl-c1">&gt;</span> <span class="pl-c1">2466</span>                 <span class="pl-s1">ret</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">empty</span>(<span class="pl-s1">shape</span>, <span class="pl-s1">dtype</span><span class="pl-c1">=</span><span class="pl-s1">dtype</span>)
   <span class="pl-c1">2467</span>             <span class="pl-k">else</span>:
   <span class="pl-c1">2468</span>                 <span class="pl-s1">ret</span> <span class="pl-c1">=</span> <span class="pl-s1">node</span>[<span class="pl-s1">start</span>:<span class="pl-s1">stop</span>]

<span class="pl-v">TypeError</span>: <span class="pl-v">Invalid</span> <span class="pl-s1">datetime</span> <span class="pl-s1">unit</span> <span class="pl-c1">in</span> <span class="pl-s1">metadata</span> <span class="pl-s1">string</span> <span class="pl-s">"[ns, UTC]"</span></pre></div>
<h4 dir="auto">Problem description</h4>
<p dir="auto">HDFStore fails to save empty/non-empty Series and empty DataFrames with timezone-aware data correctly. The issue is that the timezone information is not being saved correctly. For Series, there is no timezone handling at all. For DataFrames, the timezone handling is skipped when empty.</p>
<h4 dir="auto">Expected Output</h4>
<p dir="auto">The checks should pass.</p>
<h4 dir="auto">Output of <code class="notranslate">pd.show_versions()</code></h4>
<details>
<h2 dir="auto">INSTALLED VERSIONS</h2>
<p dir="auto">commit: None<br>
python: 2.7.12.final.0<br>
python-bits: 64<br>
OS: Linux<br>
OS-release: 4.4.0-1049-aws<br>
machine: x86_64<br>
processor: x86_64<br>
byteorder: little<br>
LC_ALL: None<br>
LANG: en_US.UTF-8<br>
LOCALE: None.None</p>
<p dir="auto">pandas: 0.22.0<br>
pytest: 3.5.0<br>
pip: 9.0.3<br>
setuptools: 39.0.1<br>
Cython: 0.28.1<br>
numpy: 1.14.2<br>
scipy: 1.0.1<br>
pyarrow: 0.9.0<br>
xarray: None<br>
IPython: 5.6.0<br>
sphinx: None<br>
patsy: None<br>
dateutil: 2.7.2<br>
pytz: 2018.3<br>
blosc: None<br>
bottleneck: None<br>
tables: 3.4.2<br>
numexpr: 2.6.4<br>
feather: None<br>
matplotlib: 2.2.2<br>
openpyxl: None<br>
xlrd: None<br>
xlwt: None<br>
xlsxwriter: None<br>
lxml: None<br>
bs4: None<br>
html5lib: 1.0.1<br>
sqlalchemy: None<br>
pymysql: 0.8.0<br>
psycopg2: None<br>
jinja2: 2.10<br>
s3fs: None<br>
fastparquet: None<br>
pandas_gbq: None<br>
pandas_datareader: None</p>
</details>