Jupyter中的熊猫自动补全问题

Sos*_*osi 7 python pandas jupyter jupyter-notebook

我遇到了与此用户类似的问题:调用autocomplete时df.col.,即使评估了仅包含一个单元格也没有自动完成df.col。例如,我希望看到df.col.str.matc自动完成df.col.str.match。我该怎么解决?

以以下数据框为例:

import pandas as pd
data = [['Alex in FL','ten'],['Bob in FLORIDA','five'],['Will in GA','three']]
df = pd.DataFrame(data,columns=['Name','Age'])

#Dataframe:
    Name             Age
0   Alex in FL       ten
1   Bob in FLORIDA   five
2   Will in GA       three

#Command that should autocomplete (but does not):
df.Name.str.matc [+TAB]
Run Code Online (Sandbox Code Playgroud)

我不想尝试腹地,因为我只想在按Tab时自动完成。

在此先多谢!

vb_*_*ses 4

读完这篇文章后,似乎其他人和特定版本的 ipython 都面临这个问题。该链接上也给出了解决方案。

是这样的:

从终端运行以下命令:

ipython profile create
Run Code Online (Sandbox Code Playgroud)

它将创建一个默认配置文件~/.ipython/profile_default/ipython_config.py

现在编辑它ipython_config.py并添加以下行即可解决问题。

c = get_config()
c.Completer.use_jedi = False
Run Code Online (Sandbox Code Playgroud)

参考:

  1. https://github.com/jupyter/notebook/issues/2435
  2. https://ipython.readthedocs.io/en/stable/config/intro.html