以下代码产生分段故障。
import pandas as pd
from mock import MagicMock
df = pd.DataFrame(0, [[1, 2], [3, 4]], ['col'])
df['col'] += MagicMock()
天真,我希望这会起作用。这是模拟数据框的正确方法吗?
print pd.Show_versions()
INSTALLED VERSIONS
------------------
commit: None
python: 2.7.12.final.0
python-bits: 64
OS: Linux
OS-release: 4.4.0-142-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US
LOCALE: None.None
pandas: 0.24.1
pip: 19.0.2
setuptools: 40.8.0
numpy: 1.16.1
scipy: 1.2.1
dateutil: 2.8.0
pytz: 2018.9
sqlalchemy: 1.2.17
psycopg2: 2.7.7 (dt dec pq3 ext lo64)
在以下github问题中讨论/修复了此错误/pr-
- https://github.com/pandas-dev/pandas/issues/25332
- https://github.com/numpy/numpy/issues/12982
- https://github.com/numpy/numpy/pull/13992