无法在Jupyter Notebook中导入或安装熊猫配置文件

时间:2019-06-24 21:46:25

标签: python pandas pip jupyter-notebook pandas-profiling

从技术上讲,我已经使用

安装了pandas-profiling

pip install pandas-profiling

但是当我尝试导入它时,出现以下错误:

import numpy as np
import pandas as pd
import pandas_profiling
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-1-e1a23f2a6f04> in <module>()
  1 import numpy as np
  2 import pandas as pd
  3 import pandas_profiling

  ModuleNotFoundError: No module named 'pandas_profiling'

First Error Image

所以我尝试在Jupyter Notebook中安装它,并且也收到以下错误:

import sys
!{sys.executable} -m pip install pandas-profiling

 Collecting pandas-profiling
 Could not find a version that satisfies the requirement pandas-profiling 
 (from versions: )
 No matching distribution found for pandas-profiling

Second Error Image

由于某种原因,由于无法建立与conda.anaconda.org的连接,我也无法同时使用conda进行安装。

3 个答案:

答案 0 :(得分:1)

基于评论,我能够找出问题所在。我必须在Anaconda root env外部安装jupyter笔记本,然后从终端打开它。

pip3 install jupyter notebook

一旦我正确地导入了它。

答案 1 :(得分:0)

步骤:

  1. Download the ZIP
  2. 打开Anaconda Prompt并转到目录,然后将文件提取到文件夹中
  

cd   C:\ Users \ farah \ Downloads \ pandas-profiling-master \ pandas-profiling-master

  1. 然后键入python setup.py install

  2. 现在您可以使用:

import pandas_profiling as pp
df = pd.read_csv('1234.csv')
pp.ProfileReport(df)

参考:Pandas profiling

答案 2 :(得分:0)

对于其他希望解决此问题的人,请尝试以下替代步骤:

  1. 在jupyter笔记本的单独单元格中运行WITH CTE AS( SELECT ID, Email, ROW_NUMBER() OVER (PARTITION BY ID ORDER BY Email_Date DESC) AS Email_RN, Phone, ROW_NUMBER() OVER (PARTITION BY ID ORDER BY Phone_Date DESC) AS Phone_RN FROM YourTable) SELECT ID, MAX(CASE Email_RN WHEN 1 THEN Email END) AS Email, MAX(CASE Phone_RN WHEN 1 THEN Phone END) AS Phone FROM CTE GROUP BY ID; 命令。
  2. 之后,只需重新启动内核,然后再次运行即可。这绝对应该工作。为我工作。