The most simple way is .iloc[[0, -1]]. Refer to the following code: df = pd.DataFrame({'a':range(1,5), 'b':['a','b','c','d']}). df2 = df.iloc[[0, -1]].
確定! 回上一頁