## How to find all possible daughters in a sequence of numbers stored in dataframe

Question

I have a python dataframe which one of its column such as `column1`

contains series of numbers. I have to mention that each these numbers are the result of cell mutation so cell with number `n`

deviates to two cells with following numbers: `2*n`

and `2*n+1`

. I want to search in this column to find all rows corresponds to daughters of specific number `k`

. I mean the rows which contains all possible `{2*k, 2*k+1, 2*(2*k), 2*(2*k+1), ... }`

in their `column1`

. I don't want to use tree structure, how can I approach the solution ? thanks

Show source

## Answers to How to find all possible daughters in a sequence of numbers stored in dataframe ( 2 )

Ugly but seems to work alright. What I think you might have needed to know is the newer

`yield from`

construction. Used twice in this code. Never thought I would.Couple of representative results:

The two sequences look like the numbers who's binary expansion starts with

`10`

and the numbers for which the binary expansion starts with`11`

.Both sequences can be found directly:

EDIT:

For an arbitrary starting point, you can do the following, which I think meets your criteria.

Checking those sequences against OEIS:

Which means you can simply do: