我好像打不到电话系列.get在一个系列对象上。在
>> print col
0 1
1 1
2 0
Name: a, dtype: float64
>>> counts = col.value_counts()
>>> print counts
1 2
0 1
dtype: int64
。。。有道理。2个一。1零
^{pr2}$。。。好 啊。结果是一系列的。我怎样才能读出元素?根据Series.get,和计数。获取,我应该能够:
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
在:
>>> print counts
1 2
0 1
1和0不是标签吗?在
似乎是熊猫15号的虫子
升级到熊猫18解决了这个问题。在
相关问题 更多 >
编程相关推荐