how to implement the format for row count

85 views Asked by At

I have a dataframe which has a list of names and email add, for example: enter image description here

using yagmail i want to send a text to the email add in DataFrame.

Desired output should be like this mark->

sending email 1/3

jess->

sending email 2/3

riza ->

sending email 3/3

i used this approach:

for i in range(0, len(df1.index)):
            print(f'sending email {str(df1.index[i])}/{len(df)}')

the output i am getting is:

mark->

sending email 1/3 sending email 2/3 sending email 3/3

jess->

sending email 1/3 sending email 2/3 sending email 3/3

riza ->

sending email 1/3 sending email 2/3 sending email 3/3

what did i do wrong?

1

There are 1 answers

1
Venkat J On
import pandas as pd

raw = { "Name": ["Mark", "Jess"],
        "Gmail": ["[email protected]", "[email protected]"]}
df = pd.DataFrame(raw, columns=['Name', 'Gmail'])

res = [x + '-> ' + 'Sending Email' for x in df['Name']]
ind = [str(y)+'/'+str(len(df)) for y in df.index]

for i in range(0,len(res)):
    print(res[i] + ' ' + ind[i])

Above code will solve your problem