To select all rows except the last one in a pandas DataFrame using .loc
indexing, you can use the following code:
main.py121 chars2 lines
However, if it's not giving you the last row, it's possible that the index of your DataFrame is not sequential. In that case, you can reset the index and then use .loc
indexing:
main.py144 chars2 lines
This will create a new DataFrame with the index reset and exclude the last row.
gistlibby LogSnag