gpt4 book ai didi

python - 朱皮特 : Line magic function not found

转载 作者:行者123 更新时间:2023-12-01 00:40:26 25 4
gpt4 key购买 nike

我遇到了一个持续错误:

%%writefile csvmagic.py
import pandas as pd
from io import StringIO

def csv(line, cell):
sio = StringIO(cell)
return pd.read_csv(sio)

def load_ipython_extension(ipython):
"""This function is called when the extension is
loaded. It accepts an IPython InteractiveShell
instance. We can register the magic with the
`register_magic_function` method of the shell
instance."""
ipython.register_magic_function(csv, 'cell')

Overwriting csvmagic.py



%reload_ext csvmagic
%%csv
col1,col2,col3
0,1,2
3,4,5
7,8,9

UsageError: Line magic function `%%csv` not found.

Line magic”对我来说看起来不太正确,但我无法弄清楚。

来源是here

最佳答案

Afaik,您必须将单元魔法放在单元的开头。但是,%%csv 在您的代码块内。确保以 %%csv 开头的部分位于其自己的单元格中。否则,细胞魔法将被解释为线条魔法。

关于python - 朱皮特 : Line magic function not found,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57387296/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com