- mongodb - 在 MongoDB mapreduce 中,如何展平值对象?
- javascript - 对象传播与 Object.assign
- html - 输入类型 ="submit"Vs 按钮标签它们可以互换吗?
- sql - 使用 MongoDB 而不是 MS SQL Server 的优缺点
导入 pandas 并没有引发错误,而是尝试读取挑选的 pandas 数据框:
import numpy as np
import pandas as pd
import matplotlib
import seaborn as sns
sns.set(style="white")
control_data = pd.read_pickle('null_report.pickle')
test_data = pd.read_pickle('test_report.pickle')
回溯是 165 行,包含三个并发异常(无论这意味着什么)。 read_pickle
是否与我正在运行的 pandas 17.1 版不兼容?如何解开我的数据框以供使用?
以下是回溯的副本:
ImportError Traceback (most recent call last)
C:\Users\test\Anaconda3\lib\site-packages\pandas\io\pickle.py in try_read(path, encoding)
45 with open(path, 'rb') as fh:
---> 46 return pkl.load(fh)
47 except (Exception) as e:
ImportError: No module named 'pandas.indexes'
During handling of the above exception, another exception occurred:
ImportError Traceback (most recent call last)
C:\Users\test\Anaconda3\lib\site-packages\pandas\io\pickle.py in try_read(path, encoding)
51 with open(path, 'rb') as fh:
---> 52 return pc.load(fh, encoding=encoding, compat=False)
53
C:\Users\test\Anaconda3\lib\site-packages\pandas\compat\pickle_compat.py in load(fh, encoding, compat, is_verbose)
115
--> 116 return up.load()
117 except:
C:\Users\test\Anaconda3\lib\pickle.py in load(self)
1038 assert isinstance(key, bytes_types)
-> 1039 dispatch[key[0]](self)
1040 except _Stop as stopinst:
C:\Users\test\Anaconda3\lib\pickle.py in load_stack_global(self)
1342 raise UnpicklingError("STACK_GLOBAL requires str")
-> 1343 self.append(self.find_class(module, name))
1344 dispatch[STACK_GLOBAL[0]] = load_stack_global
C:\Users\test\Anaconda3\lib\pickle.py in find_class(self, module, name)
1383 module = _compat_pickle.IMPORT_MAPPING[module]
-> 1384 __import__(module, level=0)
1385 if self.proto >= 4:
ImportError: No module named 'pandas.indexes'
During handling of the above exception, another exception occurred:
ImportError Traceback (most recent call last)
C:\Users\test\Anaconda3\lib\site-packages\pandas\io\pickle.py in read_pickle(path)
59 try:
---> 60 return try_read(path)
61 except:
C:\Users\test\Anaconda3\lib\site-packages\pandas\io\pickle.py in try_read(path, encoding)
56 with open(path, 'rb') as fh:
---> 57 return pc.load(fh, encoding=encoding, compat=True)
58
C:\Users\test\Anaconda3\lib\site-packages\pandas\compat\pickle_compat.py in load(fh, encoding, compat, is_verbose)
115
--> 116 return up.load()
117 except:
C:\Users\test\Anaconda3\lib\pickle.py in load(self)
1038 assert isinstance(key, bytes_types)
-> 1039 dispatch[key[0]](self)
1040 except _Stop as stopinst:
C:\Users\test\Anaconda3\lib\pickle.py in load_stack_global(self)
1342 raise UnpicklingError("STACK_GLOBAL requires str")
-> 1343 self.append(self.find_class(module, name))
1344 dispatch[STACK_GLOBAL[0]] = load_stack_global
C:\Users\test\Anaconda3\lib\pickle.py in find_class(self, module, name)
1383 module = _compat_pickle.IMPORT_MAPPING[module]
-> 1384 __import__(module, level=0)
1385 if self.proto >= 4:
ImportError: No module named 'pandas.indexes'
During handling of the above exception, another exception occurred:
ImportError Traceback (most recent call last)
C:\Users\test\Anaconda3\lib\site-packages\pandas\io\pickle.py in try_read(path, encoding)
45 with open(path, 'rb') as fh:
---> 46 return pkl.load(fh)
47 except (Exception) as e:
ImportError: No module named 'pandas.indexes'
During handling of the above exception, another exception occurred:
ImportError Traceback (most recent call last)
C:\Users\test\Anaconda3\lib\site-packages\pandas\io\pickle.py in try_read(path, encoding)
51 with open(path, 'rb') as fh:
---> 52 return pc.load(fh, encoding=encoding, compat=False)
53
C:\Users\test\Anaconda3\lib\site-packages\pandas\compat\pickle_compat.py in load(fh, encoding, compat, is_verbose)
115
--> 116 return up.load()
117 except:
C:\Users\test\Anaconda3\lib\pickle.py in load(self)
1038 assert isinstance(key, bytes_types)
-> 1039 dispatch[key[0]](self)
1040 except _Stop as stopinst:
C:\Users\test\Anaconda3\lib\pickle.py in load_stack_global(self)
1342 raise UnpicklingError("STACK_GLOBAL requires str")
-> 1343 self.append(self.find_class(module, name))
1344 dispatch[STACK_GLOBAL[0]] = load_stack_global
C:\Users\test\Anaconda3\lib\pickle.py in find_class(self, module, name)
1383 module = _compat_pickle.IMPORT_MAPPING[module]
-> 1384 __import__(module, level=0)
1385 if self.proto >= 4:
ImportError: No module named 'pandas.indexes'
During handling of the above exception, another exception occurred:
ImportError Traceback (most recent call last)
<ipython-input-17-3b05fe7d20a4> in <module>()
3 # test_data = np.genfromtxt(fh, usecols=2)
4
----> 5 control_data = pd.read_pickle('null_report.pickle')
6 test_data = pd.read_pickle('test_report.pickle')
7
C:\Users\test\Anaconda3\lib\site-packages\pandas\io\pickle.py in read_pickle(path)
61 except:
62 if PY3:
---> 63 return try_read(path, encoding='latin1')
64 raise
C:\Users\test\Anaconda3\lib\site-packages\pandas\io\pickle.py in try_read(path, encoding)
55 except:
56 with open(path, 'rb') as fh:
---> 57 return pc.load(fh, encoding=encoding, compat=True)
58
59 try:
C:\Users\test\Anaconda3\lib\site-packages\pandas\compat\pickle_compat.py in load(fh, encoding, compat, is_verbose)
114 up.is_verbose = is_verbose
115
--> 116 return up.load()
117 except:
118 raise
C:\Users\test\Anaconda3\lib\pickle.py in load(self)
1037 raise EOFError
1038 assert isinstance(key, bytes_types)
-> 1039 dispatch[key[0]](self)
1040 except _Stop as stopinst:
1041 return stopinst.value
C:\Users\test\Anaconda3\lib\pickle.py in load_stack_global(self)
1341 if type(name) is not str or type(module) is not str:
1342 raise UnpicklingError("STACK_GLOBAL requires str")
-> 1343 self.append(self.find_class(module, name))
1344 dispatch[STACK_GLOBAL[0]] = load_stack_global
1345
C:\Users\test\Anaconda3\lib\pickle.py in find_class(self, module, name)
1382 elif module in _compat_pickle.IMPORT_MAPPING:
1383 module = _compat_pickle.IMPORT_MAPPING[module]
-> 1384 __import__(module, level=0)
1385 if self.proto >= 4:
1386 return _getattribute(sys.modules[module], name)[0]
ImportError: No module named 'pandas.indexes'
我也试过直接从pickle加载pickle文件:
via_pickle = pickle.load(open('null_report.pickle', "rb"))
得到了同样的错误:
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-23-ba2e3adae1c4> in <module>()
1
----> 2 via_pickle = pickle.load( open( 'null_report.pickle', "rb" ) )
3
4 # control_data = pd.read_pickle('null_report.pickle')
5 # test_data = pd.read_pickle('test_report.pickle')
ImportError: No module named 'pandas.indexes'
最佳答案
当我使用 python 2.7 创建一个 pkl 文件并尝试使用 python 3.6 读取它时,我遇到了这个错误我做到了:
pd.read_pickle('foo.pkl')
成功了
关于python - 导入错误 : No module named 'pandas.indexes' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37371451/
我有一堆字符串,其中包含以姓氏,名字格式命名的名称列表,并用逗号分隔,如下所示: names 序列化字符串中的“first name last name”,我们在Stack Overflow上找到一个
在尝试合并多个数据框时,我得到了一些非常奇怪的东西。帮助! 我需要通过“RID”和“VISCODE”列合并一堆数据框。这是它的外观示例: d1 = data.frame(ID = sample(9,
让我们尽可能简单地做第一个例子。 我想知道如何应用这个宏;像这里适用于例如printf("%s",macro(arg)); #include #include #include #define
以下2个bean声明之间有什么区别吗? @Bean(name = "bean1") public A getA() { return new A(); } @Bean @Quali
if(c.get_name(&name) && name && !strcmp(name, contName)) 谁能告诉我这行代码在 C++ 中的含义 最佳答案 如果 c 有一个名字并且它等于 co
我是 Rails 的初学者,在改进我的搜索查询时遇到了一些问题: 在我调用的 Controller 中: def index if params[:search] @persons = Pers
谁能帮我解决这段代码的最后一部分的编译错误它的说法创建构造函数请帮助 public class Officer { public static void main(String args[]
关闭。这个问题需要details or clarity .它目前不接受答案。 想改进这个问题吗? 通过 editing this post 添加细节并澄清问题. 关闭 8 年前。 Improve t
我创建了一个 Web 应用程序,它具有使用 JSF 技术的 createBook.xhtml 并且它使用托管 Bean。在此页面中,用户必须在输入字段中填写所需信息,然后点击提交按钮。然后应使用 do
嘿,我正在尝试弄清楚如何将在 mySQL 中工作的语句转换为 PostgreSQL 并且很好奇是否有人知道解决方案。 这是在 mySQL 中有效的语句: def self.by_name(keywor
如果我要创建所有类型的类型,而不是使用字符串和原始类型,那么最大的缺点是什么? 通常它看起来像: String name = person.getName(); int age = person.ge
我正在尝试从以下内容中提取郊区名称: 12 street name, suburb name, CTG 1234 在 PHP 中使用正则表达式。 街道和郊区名称都可以是任意数量的单词长度。 CTG 是
我有一个呈现个人详细信息组件的父组件,并且正在注入(inject)父组件的验证器范围。如果我使用 v-validate 指令和 this.$validator.validateAll() 或 this
现在,据我了解,name[] 声明中的 extern 告诉编译器它的定义在其他地方(在我的程序中,我定义了它低于我使用它的部分)。但是为什么 strlen() 和 sizeof 会有不同的结果?str
我一直在解决一个问题: "Design a program that asks the user for a series of names (in no particular order). Aft
我的 XML 如下所示: 我想使用 JAXB 来阅读该内容。 我知道我能做到 @XmlRootElement(name="thing") public class Thing{
对于字符串 name[],我们可以使用 strlen(name)+1 和 sizeof(name) 互换 在我们的代码中没有经过深思熟虑?他们不一样吗?我检查了一下,发现两者的返回类型都是相同的,si
我正在尝试从以下内容中提取郊区名称: 12 street name, suburb name, CTG 1234 在 PHP 中使用正则表达式。 街道和郊区名称的长度可以是任意数量。 CTG 是 st
关闭。这个问题需要details or clarity .它目前不接受答案。 想改进这个问题吗? 通过 editing this post 添加细节并澄清问题. 关闭 8 年前。 Improve t
bash 手册列出了 for 的语法。复合语句为for name [ [ in [ word ... ] ] ; ] do list ; done这意味着 do 之前的分号如果 in 是可选的子句省略
我是一名优秀的程序员,十分优秀!