import numpy as np
import pandas as pd
df = pd.read_csv(r"D:\OCdata\ObesityDataSet_raw_and_data_sinthetic.csv")
# # -------按列读取
# print(df["Gender"])
# print(df[["Gender","Age"]])
# print(df.loc[:,"Age"])
# print(df.loc[:,["Gender","Age"]])
#
# # -------按行读取
# print(df.loc[3])
# print(df.loc[:3])
# print(df.loc[[1,2,3]])
# # -------行列一起用
# print(df.loc[0:3, "Age"])
# print(df.loc[0:3,["Age","Gender"]])
#
# # -------按照匹配条件提取多行
# print(df[df["Gender"] == "Male"])
Dataframe读取行读取列
最新推荐文章于 2024-07-20 03:51:06 发布