I have these datasets and this loop:
df1 = np.array([[91,9], [22,78]])
df2 = np.array([[99,1], [21,79]])
df3 = np.array([[96,4], [10,90]])
df4 = np.array([[98,2], [18,82]])
dfs = [df1, df2, df3, df4]
for i in dfs:
tpr = i[1,1] / (i[1,0] + i[1,1])
print('tpr: ', tpr)
and the output is:
tpr: 0.78
tpr: 0.79
tpr: 0.9
tpr: 0.82
How would I get an output like this?
df1 -- tpr: 0.78
df2 -- tpr: 0.79
df3 -- tpr: 0.9
df4 -- tpr: 0.82
The main issue is that I need the name of the array to be printed. I looked at a few other answers (different problems) and tried these, but can't get it to work.
For example [i]
and other things in the print statement to try and get the name.
e.g. How to print the list in 'for' loop using .format() in Python?, but the problem is different and doesn't seem to apply.