In [1]:
import pandas as pd
In [2]:
df = pd.DataFrame([[0, 10, 20], [30, 40, 50], [60, 70, 80]],
index=[2, 0, 1], columns=[1, 2, 0])
print(df)
In [3]:
print(df[0])
In [4]:
print(df[[0, 2]])
In [5]:
print(df[:2])
In [6]:
print(df[-2:])
In [7]:
print(df.loc[:2])
In [8]:
print(df.iloc[:2])
In [9]:
s = df[2]
print(s)
In [10]:
print(s[0])
In [11]:
print(s.at[0])
In [12]:
print(s.iat[0])
In [13]:
# print(s[-1])
# KeyError: -1
In [14]:
print(s.iat[-1])