noamraph / tqdm

Add a progress meter to your loops in a second
MIT License
2.78k stars 101 forks source link

Is there any way to use tqdm without for clause? #31

Closed eromoe closed 6 years ago

eromoe commented 6 years ago

I have a big pandas dataframe. I think it is effcient to select store at first then select product.

    product_ids = df.product_id.unique()
    store_ids = df.store_id.unique()

    for store_id in store_ids:
        sdf = df.loc[df['store_id']==store_id]
        for product_id in product_ids:
            new_df = sdf.loc[(sdf['product_id']==product_id) ]

But using tqdm need generate combinations of store_id and product_id . So I want to ask is there any way I can do

    product_ids = df.product_id.unique()
    store_ids = df.store_id.unique()

    bar = tqdm(total=product_ids.shape[0]*store_ids.shape[0])

    for store_id in store_ids:
        sdf = df.loc[df['store_id']==store_id]
        for product_id in product_ids:
            new_df = sdf.loc[(sdf['product_id']==product_id) ]

            bar.step()
noamraph commented 6 years ago

Hi,

I suggest that you check out github.com/tqdm/tqdm, which is being maintained.

On Wed, Aug 22, 2018, 04:48 eromoe notifications@github.com wrote:

I have a big pandas dataframe. I think it is effcient to select store at first then select product.

product_ids = df.product_id.unique()
store_ids = df.store_id.unique()

for store_id in store_ids:
    sdf = df.loc[df['store_id']==store_id]
    for product_id in product_ids:
        new_df = sdf.loc[(sdf['product_id']==product_id) ]

But using tqdm need generate combinations of store_id and product_id . So I want to ask is there any way I can do

product_ids = df.product_id.unique()
store_ids = df.store_id.unique()

bar = tqdm(total=product_ids.shape[0]*store_ids.shape[0])

for store_id in store_ids:
    sdf = df.loc[df['store_id']==store_id]
    for product_id in product_ids:
        new_df = sdf.loc[(sdf['product_id']==product_id) ]

        bar.step()

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/noamraph/tqdm/issues/31, or mute the thread https://github.com/notifications/unsubscribe-auth/ABe0OBZM9Lmnej-CfUD-fI2I-5z6hgRuks5uTLhZgaJpZM4WG26- .