简体   繁体   English

如何过滤熊猫中的列?

[英]How to filter columns in pandas?

i have a big dataset with more than 80 columns. 我有超过80列的大型数据集。

I wish to get a subset from dataset including the second column and columns from 10 to 40. 我希望从数据集中获得一个子集,包括第二列和10到40的列。

I know dt.iloc[:,10:40] gives me the column from 10 to 40 . 我知道dt.iloc[:,10:40]给我的列从1040

The question is, what is the easiest way to also include the second column to this subset as well? 问题是, 将第二列也包括到该子集中的最简单方法什么?

使用np.r_

dt.iloc[:,np.r_[1,10:40]]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM