Python aggregate functions

Source: Internet
Author: User

Description of the function/method name equivalent operator

All collection types

Len (s) set cardinality: The number of elements in the set S

Set ([obj]) variable set factory function; Obj must be an iteration supported by obj

Creates a collection of elements, or creates an empty collection

Frozenset ([obj]) immutable set factory function; The execution mode is the same as the set () method,

But it returns the immutable collection

Obj in S member test: is obj an element of s?

Obj not in S non-member test: is obj an element in s?

s = = t equivalence Test: Does the test S and t have the same elements?

s! = T is not equivalent to test: = = opposite

S < T (in strict sense) subset testing; s! = T and S in all

Elements are members of T

S.issubset (t) s <= T subset Test (allows for a subset of non-strict meanings): all elements in S

They're all members of T.

s > t (in strict sense) superset Test: s! = T and all elements of T

They're all members of S.

S.issuperset (t) s >= T-superset Test (allows for non-strict superset): all elements in t

They're all members of S.

S.union (t) s | T merge operation: elements in S or T

S.intersec-tion (t) S & T intersection operation: elements in S and T

S.difference (t) s-t differential operation: An element in S, not an element in T

S.symmetric_difference (t) s ^ t symmetric differential operation: elements in S or T, but not s and T are common

The Elements

S.copy () Copy operation: Returns a (shallow copy) copy of S

For mutable collections only

S.update (t) s |= T (Union) Modify operation: Add a member of T to the S

S.intersection_update (t) s &= T intersection modification operation: s includes only members of S and T

S.difference_update (t) s-= t Difference modification operation: s includes members that belong only to s but are not part of T

S.symmetric_

Difference_

Update (t) s ^= T symmetric differential modification operation: s contains only s or T-only

Members

S.add (obj) plus operation: adding obj to S

S.remove (obj) delete operation: Remove obj from S, if not present in S

obj, will throw Keyerror

S.discard (obj) Discard operation: A friendly version of remove ()-such as

There is an obj in the fruit s,

Remove it from S

S.pop () Pop operation: Remove and return any element in S


This article is from the "Eight Miles" blog, so be sure to keep this source http://5921271.blog.51cto.com/5911271/1721590

Python aggregate functions

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.