我有一个表“df”,其中包含以下变量和样本值:
MSISDN | TXN_DATE | DISBURSED_AMT |
---|---|---|
1.0 | 2020-09-21 | 10000.00 |
1.0 | 2020-11-03 | 10000.00 |
2.0 | 2020-11-06 | 10000.00 |
2.0 | 2020-10-22 | 6500.00 |
2.0 | 2020-09-21 | 15900.00 |
2.0 | 2020-09-08 | 15000.00 |
3.0 | 2020-11-18 | 100.00 |
3.0 | 2020-10-28 | 10000.00 |
4.0 | 2020-10-28 | 2000.00 |
4.0 | 2020-09-29 | 5000.00 |
我正在尝试运行以下查询:
# Create Features (Frequency, Recency and T) for customers
features = summary_data_from_transaction_data(
df,
customer_id_col="MSISDN",
datetime_col="TXN_DATE",
monetary_value_col="DSBSD_AMT",
freq="D",
)
features.reset_index(level=0, inplace=True)
features
但是我得到的输出如下所示,我真的无法解决问题所在,请协助。
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-51-de0968015e7d> in <module>
1 #calculating the recency, frequency, T, monetary_value
----> 2 loans_summ = lifetimes.utils.summary_data_from_transaction_data(loan_data, "MSISDN", "TXN_DATE", "DSBSD_AMT")
~\AppData\Local\Continuum\anaconda3\lib\site-packages\lifetimes\utils.py in summary_data_from_transaction_data(transactions, customer_id_col, datetime_col, monetary_value_col, datetime_format, observation_period_end, freq)
171 datetime_format,
172 observation_period_end,
--> 173 freq
174 )
175 # count all orders by customer.
~\AppData\Local\Continuum\anaconda3\lib\site-packages\lifetimes\utils.py in find_first_transactions(transactions, customer_id_col, datetime_col, monetary_value_col, datetime_format, observation_period_end, freq)
118 transactions = transactions.set_index(datetime_col).to_period(freq)
119
--> 120 transactions = transactions.ix[(transactions.index <= observation_period_end)].reset_index()
121
122 period_groupby = transactions.groupby([datetime_col, customer_id_col], sort=False, as_index=False)
~\AppData\Local\Continuum\anaconda3\lib\site-packages\pandas\core\generic.py in __getattr__(self, name)
5463 if self._info_axis._can_hold_identifiers_and_holds_name(name):
5464 return self[name]
-> 5465 return object.__getattribute__(self, name)
5466
5467 def __setattr__(self, name: str, value) -> None:
AttributeError: 'DataFrame' object has no attribute 'ix'