Python 将函数参数传递给另一个函数

Python 将函数参数传递给另一个函数,python,pandas,Python,Pandas,数据帧测向 cust_id order_date 1 2015-01-16 1 2019-12-03 2 2014-12-21 2 2015-01-10 1 2015-01-10 3 2018-01-18 3 2017-03-04 4 2019-11-05 4

数据帧测向

  cust_id   order_date    
    1       2015-01-16      
    1       2019-12-03      
    2       2014-12-21      
    2       2015-01-10      
    1       2015-01-10
    3       2018-01-18
    3       2017-03-04
    4       2019-11-05
    4       2010-01-01
    3       2019-12-06
    3       2002-01-01
    3       2018-01-01
Active function将查找在过去一个月内进行过交易且至少从网站购买了3次的客户

 def active(month_before_current_month, freq):
         df['Frequency'] = df.groupby('cust_id')['order_date'].nunique()
         df = df.groupby('customer_id')['order_date'].max().loc[lambda x:x>= 
         (datetime.date.today() - 

          datetime.timedelta(month_before_current_month*365/12))].loc[lambda 
            x: 
             x['Frequency']>=3].reset_index().rename(columns= 
            {'order_date':'Most_recent_date'})
         return df
主动(1,3)功能的输出将是:(在1个月前购买过并且到目前为止至少进行过3次交易的人)

现在,我想创建另一个功能,它使用active函数来查看我们应该花多少时间向这些客户发送传单或营销广告等

   def active_target(month_before_current_month, freq):
      df=active(month_before_current_month,freq)
      return df['Frequency'].mean()
这个很好用。但是,我想将参数传递给主动函数本身

当我这样做时:

       def active_target(**kwargs):
           df=active(month_before_current_month,freq)
           return df['Frequency'].mean()
调用活动\u目标

      active_target(active(1,freq))
          **I am getting error TypeError: active_target() takes 0 positional 
          arguments but 1 was given**

有人能帮忙吗:

你用什么称呼活动目标?请检查。编辑功能是什么?它返回什么?请检查。给出了主动函数。我编辑过。由于您已经在内部指定了
active
,请尝试调用
active\u目标(当前月份之前的月份,频率)
,python将在全局范围内查找
active
      active_target(active(1,freq))
          **I am getting error TypeError: active_target() takes 0 positional 
          arguments but 1 was given**