首页 > 解决方案 > 如何使用行中执行的最后一个变量?就像 R (Python) 中的 %>%

问题描述

我是 Python 新手,我想知道是否有办法在同一代码行中使用最后一次执行。在 R 中,您可以使用管道 (%>%) 来做到这一点。

例如:

在 R 中,您可以这样做:

list(filter(lambda x: '_LI' not in x,BI.columns))) %>% list(filter(lambda x: '_LS' not in x,.)

这与以下内容相同:

list(filter(lambda x: '_LS' not in x,list(filter(lambda x: '_LI' not in x,BI.columns))))

最后一个在 Python 中运行良好,但我更喜欢第一种方式,我想在 Python 中做同样的事情。可能吗?

标签: pythonrvariablespipe

解决方案


推荐阅读