Recursive Generator Functions

You can find previous post about Python generator function here This is something I haven't used very often but came up in a discussion. We know the generator function and recursive function. How do we create a generator function which is recursive. For example, if we have a binary tree…

Python Generator

When you use a loop to iterate over a collection of items (like list), this collection/sequence is stored in memory. For small sequences, this approach works well. but If you have to iterate over a large sequence (may be millions of records), then the memory usage may be much…

PySpark tips for beginners

Be careful when you use .collect()Do not call .collect() on RDD or data frame. Your driver may go out of memory if RDD or data frame is too large to fit on a node. Use take() function instead. You can specify the count with take that reduces the number…

Create and initialize a list in python

Create a list and initialize it with some default values. #create a list of 10 elements with default value as 0 >>> my_list = [0]*10 >>> my_list [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]Later you can assign the value to…