将 drift 记录扁平化
(record: Dict)
| 137 | |
| 138 | |
| 139 | def flatten_drift(record: Dict) -> Dict: |
| 140 | """将 drift 记录扁平化""" |
| 141 | return { |
| 142 | "timestamp": record.get("timestamp", ""), |
| 143 | "date": record.get("date", ""), |
| 144 | "user_id": record.get("user_id", ""), |
| 145 | "transition": record.get("transition", ""), |
| 146 | "score_delta": record.get("score_delta", 0), |
| 147 | "method": record.get("method", ""), |
| 148 | "checkfile_name": record.get("checkfile_name", ""), |
| 149 | "emerging_topics": json.dumps(record.get("emerging_topics", []), ensure_ascii=False), |
| 150 | "directions_added": json.dumps(record.get("directions_added", []), ensure_ascii=False), |
| 151 | "directions_removed": json.dumps(record.get("directions_removed", []), ensure_ascii=False), |
| 152 | "explanation": record.get("explanation", ""), |
| 153 | } |
| 154 | |
| 155 | |
| 156 | def export_to_csv(records: List[Dict], output_path: Path, flatten_func=None) -> None: |