Pandas 自定义行和列选择
我希望从pandas中选择自定义行和自定义列 我找到了所需行的索引,它们是Pandas 自定义行和列选择,pandas,Pandas,我希望从pandas中选择自定义行和自定义列 我找到了所需行的索引,它们是 indices_rows = [224, 290, 390, 130, 262, 338] 以及我希望在数据帧中包含的第一列的索引和最后一列的索引 index\u first=26,index\u last=56229 当我希望用 new_df = data_raw.iloc[[indices_rows],index:index_last] 我收到一个错误:ValueError:Buffer的维度数错误(预期为1,
indices_rows = [224, 290, 390, 130, 262, 338]
以及我希望在数据帧中包含的第一列的索引和最后一列的索引
index\u first=26
,index\u last=56229
当我希望用
new_df = data_raw.iloc[[indices_rows],index:index_last]
我收到一个错误:ValueError:Buffer的维度数错误(预期为1,实际为2)
我不知道为什么。因为它们是分开工作的。删除
[]
周围的索引行
:
new_df = data_raw.iloc[indices_rows,index:index_last]
因为:
new_df = data_raw.iloc[[indices_rows],index:index_last]
是:
需要:
new_df = data_raw.iloc[[224, 290, 390, 130, 262, 338],index:index_last]
new_df = data_raw.iloc[[224, 290, 390, 130, 262, 338],index:index_last]