首页 > 解决方案 > 在 Jupyter 中使用 Pandas 自动完成的问题

问题描述

我遇到了与此用户类似的问题:在调用自动​​完成时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]

我不想尝试腹地,因为我只想在按下选项卡时自动完成。

提前非常感谢!

标签: pythonpandasjupyter-notebookjupyter

解决方案


阅读内容后,似乎其他人以及特定版本的 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

推荐阅读