python-pandasHow to get last row of a dataframe
import pandas as pd
data = pd.DataFrame({
  'Vendor': ['US', 'US', 'US', 'KR', 'KR'],
  'Phone': ['ip5', 'ip6', 'ip8', 'sms', 'xi'],
  'Price': [204, 304, 102, 405, 350],
  'Used': [150, 250, 80, 320, 280]
})
last = data.iloc[-1]ctrl + c| import pandas as pdload Pandas module | pd.DataFramecreates Pandas DataFrame object | 
| .iloc[returns row by given integer position (starts from  | [-1]selects last row | 
Usage example
import pandas as pd
data = pd.DataFrame({
  'Vendor': ['US', 'US', 'US', 'KR', 'KR'],
  'Phone': ['ip5', 'ip6', 'ip8', 'sms', 'xi'],
  'Price': [204, 304, 102, 405, 350],
  'Used': [150, 250, 80, 320, 280]
})
last = data.iloc[-1]
print(last)output
Vendor     KR
Phone      xi
Price     350
Used      280
Name: 4, dtype: object
Related
More of Python Pandas
- What is opposite of melt() in Pandas
- How to convert column values to Int
- How to use multiple conditions in mask()
- How to install openpyxl module
- How to execute not equal query on dataframe
- How to use datetime type
- How to use melt() with dataframe - example
- How to drop duplicates from dataframe and keep last found
- How to convert datetime to timestamp
- How to convert datetime to date
See more codes...