There exist a vast number of operators in Python for manipulating objects. Operators are not objects themselves, but rather syntactical structures and keywords that force an operation to occur on an object. For instance, when the plus operator is placed between two integers, Python will add them together. See more examples of operators in the following code:
>>> 5 + 9 # plus operator example adds 5 and 9
14
>>> 4 ** 2 # exponentiation operator raises 4 to the second power
16
>>> a = 10 # assignment operator assigns 10 to a
>>> 5 <= 9 # less than or equal to operator returns a boolean
True
Operators can work for any type of object, not just numerical data. These examples show different objects being operated on:
>>> 'abcde' + 'fg'
'abcdefg'
>>> not (5 <= 9)
False
>>> 7 in [1, 2, 6]
False
>>> set([1,2,3]) & set([2,3,4])
set([2,3])
Visit tutorials point (http://bit.ly/2u5g5Io) to see a table of all the basic Python operators. Not all operators are implemented for every object. These examples all produce errors when using an operator:
>>> [1, 2, 3] - 3
TypeError: unsupported operand type(s) for -: 'list' and 'int'
>>> a = set([1,2,3])
>>> a[0]
TypeError: 'set' object does not support indexing
Series and DataFrame objects work with most of the Python operators.