- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
以下按预期工作。 190栏全部读入。
pd.read_csv("data.csv",
header=None,
names=columns,
# usecols=columns[:10],
nrows=10
)
我以前使用过 usecols 参数,所以我很困惑为什么它不再对我有用。我猜想简单地将前 10 个列名切片就可以了,但我继续收到“传递的 header 名称与 usecols 不匹配”错误。
我正在使用 Pandas 0.16.2。
pd.read_csv("data.csv",
header=None,
names=columns,
usecols=columns[:10],
nrows=10
)
回溯
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-44> in <module>()
3 nrows=10,
4 header=None,
----> 5 names=columns,
6 )
/.../lib/python2.7/site-packages/pandas/io/parsers.pyc in parser_f(filepath_or_buffer, sep, dialect, compression, doublequote, escapechar, quotechar, quoting, skipinitialspace, lineterminator, header, index_col, names, prefix, skiprows, skipfooter, skip_footer, na_values, na_fvalues, true_values, false_values, delimiter, converters, dtype, usecols, engine, delim_whitespace, as_recarray, na_filter, compact_ints, use_unsigned, low_memory, buffer_lines, warn_bad_lines, error_bad_lines, keep_default_na, thousands, comment, decimal, parse_dates, keep_date_col, dayfirst, date_parser, memory_map, float_precision, nrows, iterator, chunksize, verbose, encoding, squeeze, mangle_dupe_cols, tupleize_cols, infer_datetime_format, skip_blank_lines)
472 skip_blank_lines=skip_blank_lines)
473
--> 474 return _read(filepath_or_buffer, kwds)
475
476 parser_f.__name__ = name
/.../lib/python2.7/site-packages/pandas/io/parsers.pyc in _read(filepath_or_buffer, kwds)
248
249 # Create the parser.
--> 250 parser = TextFileReader(filepath_or_buffer, **kwds)
251
252 if (nrows is not None) and (chunksize is not None):
/.../lib/python2.7/site-packages/pandas/io/parsers.pyc in __init__(self, f, engine, **kwds)
564 self.options['has_index_names'] = kwds['has_index_names']
565
--> 566 self._make_engine(self.engine)
567
568 def _get_options_with_defaults(self, engine):
/.../m9tn/lib/python2.7/site-packages/pandas/io/parsers.pyc in _make_engine(self, engine)
703 def _make_engine(self, engine='c'):
704 if engine == 'c':
--> 705 self._engine = CParserWrapper(self.f, **self.options)
706 else:
707 if engine == 'python':
/.../lib/python2.7/site-packages/pandas/io/parsers.pyc in __init__(self, src, **kwds)
1070 kwds['allow_leading_cols'] = self.index_col is not False
1071
-> 1072 self._reader = _parser.TextReader(src, **kwds)
1073
1074 # XXX
pandas/parser.pyx in pandas.parser.TextReader.__cinit__ (pandas/parser.c:4732)()
pandas/parser.pyx in pandas.parser.TextReader._get_header (pandas/parser.c:7330)()
ValueError: Passed header names mismatches usecols
最佳答案
原来数据集中有 191 列(不是 190)。 Pandas 自动将我的第一列数据设置为索引。我不太清楚为什么会导致它出错,因为 usecols 中的所有列实际上都存在于已解析的数据集中。
因此,解决方案是确认名称中的列数与数据集中的列数完全对应。
另外,我找到了this GitHub 上的讨论。
关于python - Pandas 返回 "Passed header names mismatches usecols"错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31017823/
equal() 算法可以告诉我们两个序列是否匹配。mismatch() 算法也可以告诉我们两个序列是否匹配,而且如果不匹配,它还能告诉我们不匹配的位置。 mismatch() 的 4 个版本和 equ
我只是想在 emacs 中自定义一些 org-mode 导出设置,所以我做了 M-xcustomize-group组织导出 html。这是由 Customize buffer 提出的,除其他外,我着手
我正在尝试通过 ColdFusion 使用基于 HTTPS 的 SOAP WebService,但它返回“连接失败”。 在转储结果变量时,它显示: 错误详细信息:“I/O 异常:证书‘subdomai
我想匹配表单的输入:: commit a1b2c3 Author: Michael commit d3g4 Author: David 这是我写的语法: grammar commit; file
我正在尝试根据《Doing Bayesian Data Analysis: A Tutorial with R, JAGS, and Stan (2015)》一书来学习贝叶斯分析。 这本书里有例子。所
我有一些使用 java 泛型的类,一切都工作正常,直到我向类层次结构添加了一些附加层。 我想知道问题是否与“类型删除”有关,但我不确定如何表达继承来消除这个问题。 类定义: public interf
我正在尝试向我的应用程序添加一种语言,它一直运行到现在。经过一天尝试了解发生了什么,我放弃了。 这是我的问题: 我的基本语言是英语(开发语言),我的其他语言是法语。我在 Main.storyboard
我最近开始在 Go 中使用模块,但我经常遇到这样的问题,即在一台机器上一切正常,但在另一台机器上构建代码库时遇到校验和不匹配。 问题总是涉及相同的第三方依赖(github.com/ericlagerg
今天在用织梦系统搭建新站,在系统基本参数设置好了之后,像往常那样点击【确定】这个按钮,没想到却出现了Token mismatch!的提示,系统的基本参数无法改变,后经过查询,将出现Token mis
题目地址:https://leetcode.com/problems/set-mismatch/description/open in new window 题目描述 Theset S origi
在看似简单的任务上陷入了极大的困境...当我尝试隐藏 时出现类型不匹配错误多个 使用此代码的列.. 有什么更好的建议吗? 问候, Sub Hider() Sheets("Data So
大家好,我收到一个编译错误:类型不匹配。在下面的代码中。我希望你们能帮助我。谢谢! Private Sub cmbBusId_AfterUpdate() With Me .txtStOdo = App
我最近遇到了一条我从未见过的借用检查器消息,我试图理解它。这是重现它的代码(简化的,现实生活中的例子更复杂)- playground : fn foo(v1: &mut Vec, v2: &mut V
我尝试编写代码以打印Z字符。 zzzzzzz z z z z z zzzzzzz 但是当我编译这段代码时,它会抛出 D:\erlang\graphics>erlc zee
Sub Reset_Bet() Application.ScreenUpdating = False Sheets("Bet Angel").Select
我很难弄清楚这段应该是基本的代码片段出了什么问题。我想知道是否有人可以帮助我。任何想法都将非常感激,我对 VBA 还很陌生。 我的代码是: Dim table() as Variant: ta
我只是想从键盘读取整数、 double 、字符串值。它对于整数和 double 工作正常。但当涉及到字符串时,它会抛出输入不匹配异常,因此我无法从键盘读取字符串。 import java.util.S
给定一个学生花名册文件,其中第一行是类(class)中的学生人数,在接下来的几行中,我提供了他们的姓名、ID 和年龄,如下所示: 5 Mary, 1010, 15 Ben, 1
Android资源编译失败C:\Users\TTP\AndroidStudioProjects\TicCrossGame\app\src\main\res\layout\activity_main.x
found : (Int, String, Option[java.lang.String]) required: (Int, String, Option[java.lang.String])
我是一名优秀的程序员,十分优秀!