'Python - Iterate through last row and add value as a data label in plot

I'm trying to iterate through the values of the last row in my dataframe and then get the value to add as a data label to my plot. But the below doesn't work I get the error

type numpy.ndarray doesn't define __round__ method

My code is as below. If I change the str part of the text function to str = y, then the graph gives an output of [y value] i don't want the brackets I want to output the float itself. My eventual output I want is 14.9% where currently y = [14.90882042]

 for y in df_plot[-1:].T.values:
            plt.text(df_plot.index[1],y,round(y,2))
            print(y.astype(float))   

My output when i print each value print a numpy array of 1x1 rather than the value itself.

[14.90882042]
[24.05641512]
[17.16719185]
[18.61666735]
[25.25090525]


Solution 1:[1]

I think you put a comma accidentaly there, and you don't need to pass the "y" variable inside the round() function as you're already using the dot to apply te function to your variable. So that part should be like this: plt.text(df_plot.index[1], y.round(2))

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 luka1156