How to use iloc() function to Reverse Row In Python Pandas
Reversing the rows of a data frame in pandas can be done in python by invoking the iloc() function. Let us know how to reverse the rows of a data frame in pandas.
Syntax: DataFrame.iloc[]
Parameters: Index Position: Index position of rows in integer or list of integer.
Return: Data frame or Series depending on parameters
Python3
# Reverse rows using iloc() Function Data_reverse_row_1 = dataframe.iloc[:: - 1 ] # Observe the result Data_reverse_row_1 |
Output: