group-by-analysis
Installation
SKILL.md
Step1 对数据进行清洗与预处理,包括处理合并单元格、正则过滤以及分类映射。
import re
# 1. 处理合并单元格:向前填充
target_col = 'category_column'
df[target_col] = df[target_col].ffill()
# 2. 正则清洗:去除无效字符或筛选特定格式
def clean_text(text):
if pd.isna(text): return text
return re.sub(r'[^\w\s]', '', str(text)).strip()
df[target_col] = df[target_col].apply(clean_text)