One - One Code All

Blog Content

pandas的dataframe取最后一列,最后一行数据

Python 统计学-科学计算   2018-01-10 18:28:09

提取最后一列:

df.iloc[:,-1]

提取最后一行:

df.iloc[-1:]
df1.tail(1)

在Pandas pre-0.14 iloc中,在out-of-bounds访问中将提升IndexError,而.head().tail()将不会出现。


上一篇:pandas获取指定的列和行,df多列字段须是list
下一篇:pandas的dataframe 获取某一值所在的行索引

The minute you think of giving up, think of the reason why you held on so long.