Python: Why can't I use plot for the last rows of a dataframe when calling it with .tail() method, but when using iloc to define the rows it works?

Viewed 95

I have a df with columns of weeks and different stores' sales When I try to plot a the sum of sales for the last month using .tail() and sum(), it gives me a Type error:

df.tail(16).sum().plot(kind='bar')

TypeError: Empty 'DataFrame': no numeric data to plotenter image description here enter image description here But, if I used iloc, df.iloc[:-16, 1:].sum().plot(kind='bar');

It works

Why is this happening? what is the difference here in calling with the 2 methods?

Thanks

0 Answers
Related