Using If/Truth Statements with pandas¶
来源:互联网 发布:股票模拟交易系统源码 编辑:程序博客网 时间:2024/06/15 22:25
pandas follows the numpy convention of raising an error when you try to convert something to a bool. This happens in a if or when using the boolean operations, and, or, or not. It is not clear what the result of
>>>if pd.Series([False, True, False]): ...
should be. Should it be True because it’s not zero-length? False because there are False values? It is unclear, so instead, pandas raises a ValueError:
>>> if pd.Series([False, True, False]): print("I was true")Traceback ...ValueError: The truth value of an array is ambiguous. Use a.empty, a.any() or a.all().
这种情况下的布尔运算存在歧义,python不知道该以pd.Series
是否为空为判断是和否,还是以pd.Series
中是否有False
来判断是和否。
阅读全文
0 0
- Using If/Truth Statements with pandas¶
- 4.2.1 - Flow Control Using If/Else Statements
- Using UNION, EXCEPT and INTERSECT with Other Transact-SQL Statements
- 4.1. if Statements(if 语句)
- 12.3.3.5 If statements
- 4.4.1.1 if-statements
- Scala if Statements
- 12.3.3.17 Using statements
- Using Prepared Statements
- Using Prepared Statements
- C Programming Quiz: If statements
- PHP if-else-endif Statements
- Lesson 2: If statements in C
- Using Oracle Index Hints in SQL statements
- Alternative solution for using IF condition with Eval in C# Repeater
- Gandhi An Autobiography: The Story of My Experiments With Truth
- 【分享】Stanford Dataset全集之Networks with ground-truth communities
- Pretty Smart? Why We Equate Beauty With Truth
- android开发中Edittext控件横屏遮住屏幕问题!
- 神经网络中weight decay起到的做用是什么?momentum呢?normalization呢?
- android Vsync workflow
- 【AngularJS】scope根作用域;
- 命名体识别
- Using If/Truth Statements with pandas¶
- 常用软件
- 卸载tomcat后重装问题解决
- 详解js之Object.defineProperty
- 微信小程序 快捷键(windows)
- webstorm安装、激活、汉化(小白亲测可用)
- iOS广告启动页
- android智能指针之轻量级指针
- 安卓-Application Android.mk