我似乎无法在Series对象上调用Series.get。
-view
|--pages
|--admin
|--controlpanel.blade.php
|--layouts
|--admin.blade.php
......有道理。 2个。 1零
>> print col
0 1
1 1
2 0
Name: a, dtype: float64
>>> counts = col.value_counts()
>>> print counts
1 2
0 1
dtype: int64
......好的。结果是一个系列。我怎么能读出这些元素?根据{{3}}和count.get的docstring,我应该能够:
>>> print type(counts)
<class 'pandas.core.series.Series'>
...但是失败了:
zeros = counts.get(0,0)
ones = counts.get(1,0)
我误解了什么?
AttributeError: 'numpy.ndarray' object has no attribute 'values'
在:
>>> help(counts.get)
Help on method get in module pandas.core.series:
get(self, label, default=None) method of pandas.core.series.Series instance
Returns value occupying requested label, default to specified
missing value if not present. Analogous to dict.get
Parameters
----------
label : object
Label value looking for
default : object, optional
Value to return if label not in index
Returns
-------
y : scalar
不是1和0标签?
答案 0 :(得分:0)
似乎是熊猫中的错误
升级到pandas 18解决了这个问题。