MagicMocking熊猫DataFrame导致段错误

时间:2019-02-15 10:20:03

标签: python pandas mocking segmentation-fault magicmock

以下代码会产生分段错误。

import pandas as pd
from mock import MagicMock

df = pd.DataFrame(0, [[1, 2], [3, 4]], ['col'])
df['col'] += MagicMock()

我天真地希望这会起作用。这是模拟DataFrame的正确方法吗?

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)

1 个答案:

答案 0 :(得分:0)