Question: Given a dataframe, how do I calculate the probability of consecutive events using python pandas?

For example,

| Time | A | B | C |
| --- | --- | --- | --- |
| 1 | 1 | 1 | 1 |
| 2 | -1 | -1 | -1 |
| 3 | 1 | 1 | 1 |
| 4 | -1 | -1 | -1 |
| 5 | 1 | 1 | 1 |
| 6 | -1 | -1 | -1 |
| 7 | 1 | 1 | 1 |
| 8 | -1 | 1 | 1 |
| 9 | 1 | -1 | 1 |
| 10 | -1 | 1 | -1 |

In this dataframe, B has two consecutive "1" in t=7 and t=8, and C has three consecutive "1" in t=7 to to=9.

Probability of event that two consecutive "1" appear is 3/27
Probability of event that three consecutive "1" appear is 1/24

How can I do this using python pandas?

Answer: 
If you read the documentation a bit further, you'll see that constraint arguments on the `Container` itself will override this behavior:

> 
> Containers with no children try to be as big as possible unless the incoming constraints are unbounded, in which case they try to be as small as possible. Containers with children size themselves to their children. The width, height, and constraints arguments to the constructor override this.
> 
> 
> 

Try wrapping the inner childless `Container` in an `UnconstrainedBox`, and you'll see it will shrink to zero width and height.

```
body: 
   Container(
    color: Colors.red,
    width: double.infinity,
    height:double.infinity,
    child: UnconstrainedBox(
      child: Container(
        color: Colors.green,
      ),
    ),
)

```
Although red container has infinite size, You put it in a scaffold's body which has specific size. so your red container get specific size then your grin container with no child get size as much as its parents.