11 pandas中的運(yùn)算符 Operators in Pandas
《Python數(shù)據(jù)分析技術(shù)?!返?6章使用 Pandas 準(zhǔn)備數(shù)據(jù) 11 pandas中的運(yùn)算符 Operators in Pandas
Pandas uses the following operators that can be applied to a whole series. While Python would require a loop to iterate through every element in a list or dictionary, Pandas takes advantage of the feature of vectorization implemented in NumPy that enables these operators to be applied on every element in a sequence, eliminating the need for iteration and loops. The different types of operators are listed in Table 6-7.
Pandas 使用以下可應(yīng)用于整個(gè)序列的運(yùn)算符。Python 需要一個(gè)循環(huán)來(lái)遍歷列表或字典中的每個(gè)元素,而 Pandas 則利用了 NumPy 中實(shí)現(xiàn)的矢量化功能,使這些運(yùn)算符能夠應(yīng)用于序列中的每個(gè)元素,從而消除了遍歷和循環(huán)的需要。表 6-7 列出了不同類型的運(yùn)算符。
+addition), -(subtraction), *(multiplication),**(power),%(remainderoperator),/(division),//(floor division, for getting the quotient).
+(加法)、-(減法)、*(乘法)、**(冪)、%(余數(shù)運(yùn)算符)、/(除法)、//(底除法,用于求商)。
the functions performed by arithmetic operators can be replicated using the following methods: add for +, sub for -, mul for *, div for /, mod for %, and pow for **.
可以使用以下方法復(fù)制算術(shù)運(yùn)算符執(zhí)行的功能:"+“用 add,”-“用 sub,”*“用 mul,”/“用 div,”%“用 mod,”**"用 pow。
== ( equality),<(less than),>(greater than),<=(less than or equalto),>=(greater than or equal to),!=(not equal to)
== ( 相等),<(小于),>(大于),<=(小于或等于),>=(大于或等于),!=(不等于)
&,|,~. pandas, like numpy, uses the bitwise operators (&,|,~) as logical operators, as these operators operate on every element of a series. note that these operators are different from the logical operators used in python, where the keywords and, or, and not are used.文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-818089.html
與 numpy 一樣,pandas 使用位運(yùn)算符 (&,|,~) 作為邏輯運(yùn)算符,因?yàn)檫@些運(yùn)算符對(duì)數(shù)列中的每個(gè)元素都進(jìn)行運(yùn)算。請(qǐng)注意,這些運(yùn)算符與 python 中使用的邏輯運(yùn)算符不同,后者使用的關(guān)鍵字是 and、or 和 not。文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-818089.html
到了這里,關(guān)于《Python數(shù)據(jù)分析技術(shù)?!返?6章使用 Pandas 準(zhǔn)備數(shù)據(jù) 11 pandas中的運(yùn)算符 Operators in Pandas的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!