Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Pandas 自定义行和列选择_Pandas - Fatal编程技术网

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,

我希望从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,实际为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]