Simple Binary Classification Example in Python
The problem you are describing is a type of sequence prediction.

I think this is too complicated for any numpy or pandas library to solve. Maybe sklearn has something close, but I think a neural network would give you the most accurate predictions.

Before deciding, some of the points to consider are:


Is there a limit on max length for the string pattern you are
looking for?
Do you only want one prediction, based on one pattern that is
considered most likely, or do you want to consider multiple
patterns?
Others


Examples:
001001001 -> next digit should be 001
01001010010 -> there are 2 subpatterns and another larger pattern. next digiti could be 50% chance of 0 (01 pattern) and 50% chance of 1 (001 pattern)

I think the best approach is to let an LSTM find any patterns and predict the next digit based on the model it built. The model will contain all the information mentioned above without you needing to define them.

Depending on how simple or complicated you want to make this, you could start with a simple LSTM model and go from there. 

https://machinelearningmastery.com/sequence-prediction/

or

https://machinelearningmastery.com/models-sequence-prediction-recurrent-neural-networks/