使用jupyter notebook 4.3,Python 3.5.2 x64。
代码:
input_df2.drop('date',axis=1,inplace=True)
然后是内存错误:
MemoryError Traceback (most recent call last)
<ipython-input-52-7b522953d49a> in <module>()
----> 1 input_df2.drop('date',axis=1,inplace=True)
c:\users\jiahao\appdata\local\programs\python\python35\lib\site-packages\pandas\core\generic.py in drop(self, labels, axis, level, inplace, errors)
1906 else:
1907 new_axis = axis.drop(labels, errors=errors)
-> 1908 dropped = self.reindex(**{axis_name: new_axis})
1909 try:
1910 dropped.axes[axis_].set_names(axis.names, inplace=True)
c:\users\jiahao\appdata\local\programs\python\python35\lib\site-packages\pandas\core\frame.py in reindex(self, index, columns, **kwargs)
2819 def reindex(self, index=None, columns=None, **kwargs):
2820 return super(DataFrame, self).reindex(index=index, columns=columns,
-> 2821 **kwargs)
2822
2823 @Appender(_shared_docs['reindex_axis'] % _shared_doc_kwargs)
c:\users\jiahao\appdata\local\programs\python\python35\lib\site-packages\pandas\core\generic.py in reindex(self, *args, **kwargs)
2238 'argument "{0}"'.format(list(kwargs.keys())[0]))
2239
-> 2240 self._consolidate_inplace()
2241
2242 # if all axes that are requested to reindex are equal, then only copy
c:\users\jiahao\appdata\local\programs\python\python35\lib\site-packages\pandas\core\generic.py in _consolidate_inplace(self)
2799 self._data = self._data.consolidate()
2800
-> 2801 self._protect_consolidate(f)
2802
2803 def consolidate(self, inplace=False):
c:\users\jiahao\appdata\local\programs\python\python35\lib\site-packages\pandas\core\generic.py in _protect_consolidate(self, f)
2788 """
2789 blocks_before = len(self._data.blocks)
-> 2790 result = f()
2791 if len(self._data.blocks) != blocks_before:
2792 self._clear_item_cache()
c:\users\jiahao\appdata\local\programs\python\python35\lib\site-packages\pandas\core\generic.py in f()
2797
2798 def f():
-> 2799 self._data = self._data.consolidate()
2800
2801 self._protect_consolidate(f)
c:\users\jiahao\appdata\local\programs\python\python35\lib\site-packages\pandas\core\internals.py in consolidate(self)
3522 bm = self.__class__(self.blocks, self.axes)
3523 bm._is_consolidated = False
-> 3524 bm._consolidate_inplace()
3525 return bm
3526
c:\users\jiahao\appdata\local\programs\python\python35\lib\site-packages\pandas\core\internals.py in _consolidate_inplace(self)
3527 def _consolidate_inplace(self):
3528 if not self.is_consolidated():
-> 3529 self.blocks = tuple(_consolidate(self.blocks))
3530 self._is_consolidated = True
3531 self._known_consolidated = True
c:\users\jiahao\appdata\local\programs\python\python35\lib\site-packages\pandas\core\internals.py in _consolidate(blocks)
4519 for (_can_consolidate, dtype), group_blocks in grouper:
4520 merged_blocks = _merge_blocks(list(group_blocks), dtype=dtype,
-> 4521 _can_consolidate=_can_consolidate)
4522 new_blocks = _extend_blocks(merged_blocks, new_blocks)
4523 return new_blocks
c:\users\jiahao\appdata\local\programs\python\python35\lib\site-packages\pandas\core\internals.py in _merge_blocks(blocks, dtype, _can_consolidate)
4539 # combination of those slices is a slice, too.
4540 new_mgr_locs = np.concatenate([b.mgr_locs.as_array for b in blocks])
-> 4541 new_values = _vstack([b.values for b in blocks], dtype)
4542
4543 argsort = np.argsort(new_mgr_locs)
c:\users\jiahao\appdata\local\programs\python\python35\lib\site-packages\pandas\core\internals.py in _vstack(to_stack, dtype)
4585
4586 else:
-> 4587 return np.vstack(to_stack)
4588
4589
c:\users\jiahao\appdata\local\programs\python\python35\lib\site-packages\numpy\core\shape_base.py in vstack(tup)
232
233 """
--> 234 return _nx.concatenate([atleast_2d(_m) for _m in tup], 0)
235
236 def hstack(tup):
MemoryError:
但是,如果我重新启动jupyter笔记本并运行相同的行,它就可以了。
有什么想法解决这个问题?