Home > Back-end >  Python select 5last value of an excel column
Python select 5last value of an excel column

Time:03-04

I wonder if it is possible to retrieve the last 5 values of an excel column instead of all the values in that same column.

Currently I am able to select all the data in the column with the following piece of code:

var= pd.read_excel("Path/MyFile.xlsx",'MS3',skiprows=15)
xDate = list(var['Date'])

Is there a way to retrieve the last 5 values in this column?

CodePudding user response:

yes you can use tail like head

var.tail(5)

CodePudding user response:

you can simply go for this:

xDate[-5:]

  • Related