I have a data set I am transposing with a loop that looks like this.
x = []
for index, row in s1.iterrows():
x = row
tt = pd.DataFrame(x)
I am then using the pandas data frame to html function to send an email for each row of the s1 data frame transposed. My issue is that when I convert the series to a data frame at the end of the loop it includes the index for each iteration of the loop when it prints. So the output looks like this.
0
s1.Col1 s1.val1
s1.Col2 s1.val2
s1.Col3 s1.val3
s1.Col4 s1.val4
s1.Col5 s1.val5
s1.Col6 s1.val6
1
s1.Col1 s1.val1
s1.Col2 s1.val2
s1.Col3 s1.val3
s1.Col4 s1.val4
s1.Col5 s1.val5
s1.Col6 s1.val6
(Sorry I couldn't figure out how to put in a table)
So each email has all of the columns in the format I need but an index value of 0,1,2,3,4,5 etc. which I guess is being included as a column name. All I need to do is exclude the index value that is being output.
I am using the below code to generate the html for the email. So the object needs to be a data frame for this to work.
email = " {tt} "
email = email.format(tt=tt.to_html())
Maybe there is an easier way to this. I am basically just trying to transpose the original data set and send an email with the table for each row. Any help would be appreciated. Thanks.
s1 = s1.T