<p>要获取触发异常的实际数据,请添加额外的调试信息</p>
<blockquote>
<p>Modify <code>~/anaconda3/lib/python3.6/site-packages/pandas/core/internals.py</code></p>
</blockquote>
<p>向<code>class BlockManager()</code>添加行</p>
<pre><code>def __init__(self)
print('BlockManager blocks')
pprint(self.blocks)
print('BlockManager axes')
pprint(self.axes)
</code></pre>
<p>您将数据:</p>
^{pr2}$
<blockquote>
<p>Modify <code>~/anaconda3/lib/python3.6/site-packages/pandas/core/reshape/reshape.py</code> </p>
</blockquote>
<pre><code>def __unstack_frame(self, ...)
from pprint import pprint
print('_unstack_frame level {} fill_value {} {}'.format(level, fill_value, type(obj)))
pprint(obj)
</code></pre>
<p>您将看到以下数据:</p>
<pre>
BlockManager blocks
(FloatBlock: slice(0, 16, 1), 16 x 8, dtype: float64,)
BlockManager axes
[MultiIndex(levels=[[u'vote', u'vote2'], [False, 8, u'\n', u' ', u'\', u'aaa', u'xx']],
labels=[[0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1], [-1, 0, 1, 2, 3, 4, 5, 6, -1, 0, 1, 2, 3, 4, 5, 6]],
names=[None, u'voteId']),
Index([nan, -1, False, True, u'', u'a', u'b', u'c'], dtype='object', name=u'ballot1')]
</pre>
<p>我用另一个例子触发了一个异常:</p>
<pre>
File "/usr/lib64/python2.7/site-packages/pandas/core/internals.py", line 2902, in _rebuild_blknos_and_blklocs
raise AssertionError("Gaps in blk ref_locs")
AssertionError: Gaps in blk ref_locs
</pre>
<p>带调试信息</p>
<pre>
BlockManager blocks
(FloatBlock: [-1, -1, -1], 3 x 2, dtype: float64,)
BlockManager axes
[Index([aaa, bbb, ccc], dtype='object'), Int64Index([0, 1], dtype='int64')]
</pre>