ModuleNotFoundError:没有名为“将熊猫作为pd \ r导入”的模块

时间:2019-03-29 14:14:50

标签: python pandas machine-learning

  

ModuleNotFoundError:没有名为“将熊猫作为pd \ r导入”的模块

但在源代码“将熊猫作为pd / r导入”中没有得到任何一行

这是代码部分,与mport一样,即使在代码中导入的其他文件中也是如此。

{ 
import cv2
import numpy as np
import pandas as pd
import nltk
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.metrics import pairwise_distances
import pickle
from utils import display_img

data = pd.read_pickle('pickles/dataclean.py')

stop_words = set(nltk.corpus.stopwords.words('english'))
def nlp_preprocessing(total_text, index, column):
    if type(total_text) is not int:
        string = ""
        for words in total_text.split():
            # remove the special chars in review like '"#$@!%^&*()_+-~?>

dataclean.py

{import pandas as pd
# loading the data using pandas' read_json file.
data = pd.read_json('data/tops_fashion.json')
data = data.loc[~data['formatted_price'].isnull()]#this will remove data with no price
data =data.loc[~data['color'].isnull()]#remove data with no color
#print(sum(data.duplicated('title')))#tell about dubplicate  
from remove_duplicate import remove_dup1,remove_dup2   
data=remove_dup1(data)#removes adjacent sorted same title
data=remove_dup2(data)#this will take time approx half hour
data.to_pickle('pickels/dataclean')}

即使在Google上进行搜索,dataclean.py中也没有与mport相关的内容,但没有与此错误相关的详细信息 通常是与语法错误相关的“ mport”错误,但在尝试搜索相关模块的另一侧却没有提及此类错误

此代码与产品推荐系统有关

预期结果:应平稳运行 //错误代码 实际结果:

Traceback (most recent call last):
  File "recom.py", line 11, in <module>
    data = pd.read_pickle('pickles/dataclean.py')
  File "C:\Users\DELL\Anaconda3\lib\site-packages\pandas\io\pickle.py", line 180, in read_pickle
    return try_read(path, encoding='latin1')
  File "C:\Users\DELL\Anaconda3\lib\site-packages\pandas\io\pickle.py", line 175, in try_read
    lambda f: pc.load(f, encoding=encoding, compat=True))
  File "C:\Users\DELL\Anaconda3\lib\site-packages\pandas\io\pickle.py", line 149, in read_wrapper
    return func(f)
  File "C:\Users\DELL\Anaconda3\lib\site-packages\pandas\io\pickle.py", line 175, in <lambda>
    lambda f: pc.load(f, encoding=encoding, compat=True))
  File "C:\Users\DELL\Anaconda3\lib\site-packages\pandas\compat\pickle_compat.py", line 212, in load
    return up.load()
  File "C:\Users\DELL\Anaconda3\lib\pickle.py", line 1050, in load
    dispatch[key[0]](self)
  File "C:\Users\DELL\Anaconda3\lib\pickle.py", line 1309, in load_inst
    klass = self.find_class(module, name)
  File "C:\Users\DELL\Anaconda3\lib\site-packages\pandas\compat\pickle_compat.py", line 135, in find_class
    return super(Unpickler, self).find_class(module, name)
  File "C:\Users\DELL\Anaconda3\lib\pickle.py", line 1388, in find_class
    __import__(module, level=0)
ModuleNotFoundError: No module named 'mport pandas as pd\r'}

1 个答案:

答案 0 :(得分:1)

  File "recom.py", line 11, in <module>
    data = pd.read_pickle('pickles/dataclean.py')

//dataclean.py

{import pandas as pd

您正在尝试将Python文件作为泡菜加载。 Python和pickle是两种完全不同的格式,因此永远无法使用。我不知道您要做什么,还是谁建议您将Python代码放在​​花括号中引导,但这是我见过的人们尝试过的最疯狂的事情之一。