Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/77.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/sorting/2.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
如何在python中模仿R中的select()函数?_Python_R - Fatal编程技术网

如何在python中模仿R中的select()函数?

如何在python中模仿R中的select()函数?,python,r,Python,R,在R中,如果我想操作数据帧的列,我可以这样做: df %>% select(starts_with("main"),contains("ID"),everything(),-name) 上面的语句将以“main”开头的任何内容放在前面,然后是包含“ID”的任何内容,然后是数据帧中的每一列,最后通过删除name列来完成 我需要能够在Python中复制逻辑,但我似乎找不到类似的简单方法来实现同样的事情 这就是为什么我爱R胜过爱Python的原因之一。。。我仍然不明白为什么Python在数据分

在R中,如果我想操作数据帧的列,我可以这样做:

df %>% select(starts_with("main"),contains("ID"),everything(),-name)
上面的语句将以“main”开头的任何内容放在前面,然后是包含“ID”的任何内容,然后是数据帧中的每一列,最后通过删除name列来完成


我需要能够在Python中复制逻辑,但我似乎找不到类似的简单方法来实现同样的事情

这就是为什么我爱R胜过爱Python的原因之一。。。我仍然不明白为什么Python在数据分析中如此重要。lol你的复杂方式看起来怎么样?@ytu是的,我也喜欢R,但是我需要在脚本中实现一些东西,这些脚本需要一些在R中不可用的Python库。这就是这个包的目的,在R中使用Python。