ll1735 2016-08-30 07:48 采纳率: 0%
浏览 4600

pandas Series bool与运算

 In[101]: x.head()
Out[101]: 

0    1.559343
1    1.103526
2    0.791218
3    0.946919
4    1.120411
Name: Beta, dtype: float64

In[102]: x[~np.isnan(x) and x > x.mean() + 3 * x.std()] = x.mean() + 3 * x.std()
Traceback (most recent call last):
  File "C:\Anaconda3\lib\site-packages\IPython\core\interactiveshell.py", line 2881, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-102-4a0654e0fc5c>", line 1, in <module>
    x[~np.isnan(x) and x > x.mean() + 3 * x.std()] = x.mean() + 3 * x.std()
  File "C:\Anaconda3\lib\site-packages\pandas\core\generic.py", line 892, in __nonzero__
    .format(self.__class__.__name__))
ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().

In[103]: ~np.isnan(x)
Out[103]: 

0        True
1        True
2        True
3        True
4        True
5        True
6        True
7        True
8        True
9        True
10       True
11       True

Series不能对两个bool值进行and运算吗,bool值也是pandas.Series的序列,有什么简单办法,必须转换用a.all()这种函数吗

  • 写回答

1条回答 默认 最新

  • dabocaiqq 2017-02-08 20:36
    关注
    评论

报告相同问题?

悬赏问题

  • ¥50 易语言把MYSQL数据库中的数据添加至组合框
  • ¥20 求数据集和代码#有偿答复
  • ¥15 关于下拉菜单选项关联的问题
  • ¥20 java-OJ-健康体检
  • ¥15 rs485的上拉下拉,不会对a-b<-200mv有影响吗,就是接受时,对判断逻辑0有影响吗
  • ¥15 使用phpstudy在云服务器上搭建个人网站
  • ¥15 应该如何判断含间隙的曲柄摇杆机构,轴与轴承是否发生了碰撞?
  • ¥15 vue3+express部署到nginx
  • ¥20 搭建pt1000三线制高精度测温电路
  • ¥15 使用Jdk8自带的算法,和Jdk11自带的加密结果会一样吗,不一样的话有什么解决方案,Jdk不能升级的情况