Using iloc to get the last row of a Pandas DataFrame
Mohamad's interest is in Programming (Mobile, Web, Database and Machine Learning). He is studying at the Center For Artificial Intelligence Technology (CAIT), Universiti Kebangsaan Malaysia (UKM).
import pandas as pd
# Example DataFrame
df = pd.DataFrame({'A': [1, 2, 3], 'B': [4, 5, 6]})
# Get the last row using iloc
last_row = df.iloc[-1]
print("Last row:")
print(last_row)
output:
