通过熊猫中的名称识别多个列

dub*_*ber 2 python pandas

有没有办法使用文本匹配或正则表达式选择列的子集?

在R中将是这样的:

attach(iris) #Load the 'Stairway to Heaven' of R's built-in data sets
iris[grep(names(iris),pattern="Length")] #Prints only columns containing the word "Length"
Run Code Online (Sandbox Code Playgroud)

jor*_*ris 5

您可以filter为此使用方法(用于axis=1过滤列名)。此功能具有不同的可能性: