[Python] Generate multiple disjunct samples from a dataframe

Discussão em 'Python' iniciado por Stack, Novembro 28, 2024.

  1. Stack

    Stack Membro Participativo

    I am doing some statistic of a very large dataframe that takes sums of multiple random samples. I would like the samples to be disjuct (no number should be present in two different samples).

    Minimal example that might use some numbers multiple times:

    import polars as pl
    import numpy as np

    df = pl.DataFrame(
    {"a": np.random.random(1000)}
    )

    N_samples = 50
    N_logs = 20
    sums = [
    df.sample(N_logs).select(pl.col("a").sum()).item()
    for _ in range(N_samples)
    ]


    How to avoid multiple usage of same numbers?

    Continue reading...

Compartilhe esta Página