且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

将逻辑值与以pandas/numpy的NaN进行比较

更新时间:2023-01-22 22:09:14

第一个区别:|np.bitwise_or.它说明了#1和#2之间的区别.

first difference : | is np.bitwise_or. it explains the difference between #1 and #2.

第二个区别:由于serie_1.dtype如果为object(非同类数据),则在前两种情况下逐行进行操作.

Second difference : since serie_1.dtype if object (non homogeneous data), operations are done row by row in the two first cases.

使用向量化(#3)时:

When using vectorize ( #3):

vectorized输出的数据类型是通过调用确定的 输入的第一个元素的功能.这可以避免 通过指定otypes参数.

The data type of the output of vectorized is determined by calling the function with the first element of the input. This can be avoided by specifying the otypes argument.

对于矢量化操作,请退出对象模式.数据首先根据第一个元素进行转换(在此处为bool(nan)True),然后进行操作.

For vectorized operations, you quit the object mode. data are first converted according to first element (bool here, bool(nan) is True) and the operations are done after.