gpt4 book ai didi

python - 模块未找到错误: No module named 'mport pandas as pd\r'

转载 作者:行者123 更新时间:2023-11-30 09:43:45 33 4
gpt4 key购买 nike

ModuleNotFoundError: No module named 'mport pandas as pd\r'

但在源代码“mport pandas as 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 '"#$@!%^&*()_+-~?>

数据清理.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')}

dataclean.py 中没有任何与 mport 相关的内容,即使我在 google 上搜索了它,但没有与此错误相关的详细信息通常“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'}

最佳答案

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

//dataclean.py

{import pandas as pd

您正在尝试将 Python 文件作为 pickle 加载。 Python 和 pickle 是两种完全不同的格式,所以这是行不通的。我不知道你想做什么,也不知道谁建议你将 Python 代码放入大括号中以启动,但这是我见过的人们尝试过的最疯狂的事情之一。

关于python - 模块未找到错误: No module named 'mport pandas as pd\r' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55419362/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com