pandas.DataFrame.loc
一.函数的功能
Access a group of rows and columns by label(s) or a boolean array.
.loc[]
is primarily label based, but may also be used with a boolean array.
标签索引,根据标签查找该标签下的一组数据。
二.函数的使用
假设有如下表格(表格名df):每行的标签分别是a,b,c,每列的标签分别是A,B,C。
【案例1】取出第a行的数据。
【案例2】取出第B列的数据。
代码如下:
import pandas as pd
data_value = [
[100, 101, 102], [200, 201, 202], [300, 301, 302], # 3*3
]
df = pd.DataFrame(data_value, index=[