Jupyter中的熊猫自动补全问题

时间:2019-10-08 07:49:03

标签: python pandas jupyter-notebook jupyter

我遇到了一个问题similar to this user:在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]

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

非常感谢!

1 个答案:

答案 0 :(得分:1)

在阅读this之后,似乎其他人以及特定版本的ipython都遇到了此问题。该链接上也给出了解决方案。

是这样的:

从终端运行以下命令:

ipython profile create

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

现在编辑此ipython_config.py并添加以下几行,它将解决此问题。

c = get_config()
c.Completer.use_jedi = False

参考:

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