dfply Python X name未定义

2024-04-30 06:30:07 发布

您现在位置:Python中文网/ 问答频道 /正文

我在python中使用包dfply,它模仿R中的包dplyr。 这就是我要运行的简单代码。我已经在我的环境中加载了这个数据集'data',我只想为那个变量分组。在

    import dfply as dp
    data['CO_SPORTELLO']=data['CO_SPORTELLO'].apply(lambda x: str(x))
    data=(data >> 
          dp.group_by(X.CO_SPORTELLO)) 

我一直获取的错误是:NameError: name 'X' is not defined。在

从软件包文档:

The DataFrame as it is passed through the piping operations is represented by the symbol X. It records the actions you want to take (represented by the Intention class), but does not evaluate them until the appropriate time. Operations on the DataFrame are deferred. Selecting two of the columns, for example, can be done using the symbolic X DataFrame during the piping operations.

^{pr2}$

Tags: thedataframedatabyisasnotdp