如何提取没有索引号的特定列。以及 python 数据框中的所有行?

Gou*_*tam 7 python python-3.x

#df

index  a   b   c
1      2   3   4
2      3   4   5
Run Code Online (Sandbox Code Playgroud)

请帮助我如何提取包含所有行但没有索引列的“a”和“c”列。

df[["a","c"]] # 但是索引没有。也来了,那么如何去掉索引号呢?

rus*_*ro1 7

DataFrames 和 Series 将始终有一个索引,您可以使用:

df[["a","c"]].values
Run Code Online (Sandbox Code Playgroud)

输出:

array([[2, 4],
       [3, 5]], dtype=int64)
Run Code Online (Sandbox Code Playgroud)