1234567891011121314151617181920212223242526272829303132333435363738 |
- """
- @author: zsc
- @time: 2024/11/18
- @desc: 数据处理
- """
- from collections import defaultdict
- class DataPreprocessor:
- def __init__(self, data):
- self.data = data
- def preprocess(self):
-
-
- preprocessed_data = []
- for user_actions in self.data:
- user = user_actions['user']
- process = user_actions['process']
- actions = user_actions['actions']
- product = user_actions['product']
- channel = user_actions['channel']
-
-
- preprocessed_actions = [action.lower() for action in actions]
- preprocessed_data.append({
- 'user': user,
- 'process': process,
- 'actions': preprocessed_actions,
- 'product': product,
- 'channel': channel
- })
- return preprocessed_data
|