DeQue:

Collection Module in Python for Data Science:

The module collections is there for Deque implementation in Python. We prefer DeQue over list in cases where we need quicker append and pop operations from both ends of container. DeQue provides O(1) time complexity for append and pop operations. On the other hand, list provides O(n) time complexity.

Operations on DeQue:
  1. append(): It is a function that is there for inserting the value in its arguments to the right end of deque.
  2. appendleft(): It is a function that is there for inserting the value in its arguments to the left end of deque.
  3. pop(): It is a function there for deleting an argument from the right end of deque.
  4. popleft():is a function there for deleting an argument from the left end of deque.What is DeQue in Python for Data Science - PST Analytics
  5. index(ele, beg, end): It is a function which returns the first index of values mentioned in arguments. It starts searching from beginning till end index.
  6. insert(i, a): It is a function which inserts the value mentioned in arguments ‘a’ at index ‘i’ which is specified in the arguments.
  7. remove(): It is a function that removes the first occurrence of values that are mentioned in the argument.
  8. count(): This is a function that counts the number of occurrences of the values which are mentioned in the argument.What is DeQue in Python for Data Science - PST Analytics
  9. extend(iterable): It is a function which is there for adding multiple values at the right end of deque. The argument which is pass is an iterable.
  10. extendleft(iterable): It is a function there for adding multiple values at the left end of deque. The argument which is pass is an iterable. The order is reverse as a resultant of left appends.
  11. reverse(): It is a function there for reversing the order of deque elements.
  12. rotate(): This is a function which rotates the deque by a number which is specific in the argument. In case we provide a negative number as argument, the rotation occurs to the left; otherwise rotation occurs to the right.

What is DeQue in Python for Data Science - PST Analytics

To learn more about DeQue in python for data science, you can check this and this as well.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.